| Author |
how to get 3 days less than current date in java
|
Praveen palukuri
Ranch Hand
Joined: Feb 10, 2005
Posts: 65
|
|
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
Joined: Apr 21, 2005
Posts: 410
|
|
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
Joined: Feb 08, 2004
Posts: 1281
|
|
use og setLenient() wont help:
Wed Jun 29 14:23:08 BST 2005
|
java amateur
|
 |
Tim West
Ranch Hand
Joined: Mar 15, 2004
Posts: 539
|
|
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
|
 |
 |
|
|
subject: how to get 3 days less than current date in java
|
|
|