This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get 3 days less than current date in java

 
Praveen palukuri
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
this is praveen, now i have one problem before me.
"I need to display 3 days less than current date". this we can do manually by getting current date & subtracting that from 3. this is fine if date is in a month or year but when month or year is changed then we need to write lot of code.
so pls help me if any one know's simple solution for this.
thank u.
 
Stuart Gray
Ranch Hand
Posts: 410
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Calendar class can do this, and if you use disable the lenient parsing, it will handle the situations you describe too I believe:

Note that according to the API docs the Calendar version of roll is broken, but the overridden version in GregorianCalendar does the right thing. Thats why I didn't declare cal to be a Calendar in the code above.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use og setLenient() wont help:

Wed Jun 29 14:23:08 BST 2005
 
Tim West
Ranch Hand
Posts: 539
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't necessarily the most API-correct way to do it, but:



The result:



If you want to run this code, you'll have to implemnt formatAsIso8601 yourself though ;-)


-Tim
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic