Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get previous date

 
trupti nigam
Ranch Hand
Posts: 627
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why dont you use the add function of java.util.Calendar class
 
trupti nigam
Ranch Hand
Posts: 627
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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......
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic