wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Get the previous date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Get the previous date" Watch "Get the previous date" New topic
Author

Get the previous date

Makong
Greenhorn

Joined: Oct 18, 2001
Posts: 2
Hi,
i just want to know how can i get the previous date, let's say the date of yesterday.. like this:
yesterday is "2001-10-19"
tanks.
Laurent S
Greenhorn

Joined: Sep 27, 2001
Posts: 15
You can work with the class Date
public Date Yesterday(Date d) { return new Date(d.getTime() - (24*60*60*1000));}
Thomas Suer
Ranch Hand

Joined: Sep 03, 2001
Posts: 50
To format the date in your desired use the class SimpleDateFormat, for instance:
<code>
Date now = new Date();
SimpleDateFormat myTimeFormat = new SimpleDateFormat("yyyy-MM.dd");
String strDate = myTimeFormat.format(now);</code>
Look at http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html
Tom
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get the previous date
 
Similar Threads
dates in java
Date in java
get the Yesterday's date ??
Help with next day and previous day
how can i get previous date?