rockies1
Jul 1st, 2003, 02:34 PM
I have some code that works to calculate yesterday's date and it has worked great, until today.
Anyone have something that works correctly?
Here's mine:
public static String CalcYestDate()
{
//Set up date to run for
java.util.Calendar gc;
java.util.Date curDate;
String strCurDate = null;
String fileDate = new String();
gc = GregorianCalendar.getInstance ( ); // Gets the current Calendar instance
gc.roll(gc.DATE,false);
curDate = gc.getTime ( ); // Gets the Date time part of gc
SimpleDateFormat sdf2 = new SimpleDateFormat ( "yyyyMMdd" ); //sets up the correct format for the date
fileDate = sdf2.format ( curDate ); //Changes the date into the correct date format
return(fileDate);
}//End CalcYestDate
When I ran it today it returned 20030731 instead of 20030630.
Thanks!
Morgan
Anyone have something that works correctly?
Here's mine:
public static String CalcYestDate()
{
//Set up date to run for
java.util.Calendar gc;
java.util.Date curDate;
String strCurDate = null;
String fileDate = new String();
gc = GregorianCalendar.getInstance ( ); // Gets the current Calendar instance
gc.roll(gc.DATE,false);
curDate = gc.getTime ( ); // Gets the Date time part of gc
SimpleDateFormat sdf2 = new SimpleDateFormat ( "yyyyMMdd" ); //sets up the correct format for the date
fileDate = sdf2.format ( curDate ); //Changes the date into the correct date format
return(fileDate);
}//End CalcYestDate
When I ran it today it returned 20030731 instead of 20030630.
Thanks!
Morgan