Two Laptop Bag*
The moose likes Beginning Java and the fly likes How to get previous date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to get previous date" Watch "How to get previous date" New topic
Author

How to get previous date

trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
Hi All,

I am getting the date from database in String format.
I convert that to Date using simpleDateFormat class.
How do I get the previous date, from the date I get from database?

I read that deleting 24*60*60*1000 from today's date is not always reliable.
Any pointers appreciated.

Thanks,
Trupti
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 978
why dont you use the add function of java.util.Calendar class
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
Originally posted by A Kumar:
why dont you use the add function of java.util.Calendar class


Can you give an example?

Thanks
Trupti
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 978
i havent compiled this.... but do check ..it up...


Calendar cal=new Calendar(); //gregorian calendar can also be considered

cal.setTime(Date mydatefromdatabase);

cal.add(Calendar.DATE,-1);


Try this......
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get previous date
 
Similar Threads
jsp page to mysql database.
Regarding Bulk insert
java date
dates in java
Current date - 10