It's not a secret anymore!
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

Calculate Yesterday's date

Naveen R R

Joined: May 04, 2001
Posts: 20
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
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
I agree. Here's the link:
subject: Calculate Yesterday's date
jQuery in Action, 3rd edition