How can I get yesterday's date?

Joe Sam Shirah


  // get Calendar with current date
  java.util.GregorianCalendar gCal = 
               new GregorianCalendar();

  // get yesterday's date
  gCal.add( Calendar.DATE, -1 );

  // get components of yesterday's date
  String sMonth = ( gCal.get( Calendar.MONTH ) + 1 ) + "";
  String sDay   = gCal.get( Calendar.DATE )  + "";
  String sYear  = gCal.get( Calendar.YEAR )  + "";

  // get yesterday's date in milliseconds
  long lMillis = gCal.getTime().getTime();  
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact