This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get previous date

 
trupti nigam
Ranch Hand
Posts: 625
  • 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: 625
  • 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