I have the following code for calculating yesterday's date:Yesterday, however, it calculated 083104 instead of 073104.Code: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 ( "MMddyy" ); //sets up the correct format for the date fileDate = sdf2.format ( curDate ); //Changes the date into the correct date format return(fileDate); }//End CalcYestDate
Anyone know of a more accurate method?




Reply With Quote