aspose file tools*
The moose likes Servlets and the fly likes Calculate Yesterday's date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Calculate Yesterday Watch "Calculate Yesterday New topic
Author

Calculate Yesterday's date

Naveen R R
Greenhorn

Joined: May 04, 2001
Posts: 20
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

Joined: Sep 20, 2001
Posts: 58
To get yday use following...
new Date(System.currentTimeMillis() -(24*60*60*1000))
Hope this will help u...


Yogen Vadnere
 
Consider Paul's rocket mass heater.
 
subject: Calculate Yesterday's date