Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calculate Yesterday's date

 
Naveen R R
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to calculate yesterday's date. Could anyone help me with this?
java.util.Date today = new java.util.Date();
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("MM/dd/yyyy");
java.util.Date yesterday = (today) - 1; //ERROR
v.addElement(df.format(yesterday));
Thanks,
Naveen
 
Yogen Vadnere
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get yday use following...
new Date(System.currentTimeMillis() -(24*60*60*1000))
Hope this will help u...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic