| Author |
Date for last month
|
sam davis
Greenhorn
Joined: Jun 16, 2003
Posts: 18
|
|
Hello, Could someone help me out with the code to get the date for one month ago(last month)...and how would i account for the date rollover(when the year changes) i would really appreciate it..thanks..
|
 |
Joel McNary
Bartender
Joined: Aug 20, 2001
Posts: 1815
|
|
Use java.util.Calendar to accomplish this.
|
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
|
 |
sam davis
Greenhorn
Joined: Jun 16, 2003
Posts: 18
|
|
|
Thanks Joel for your help. However, i found roll() method to be better. Appreciate your help ..
|
 |
Joel McNary
Bartender
Joined: Aug 20, 2001
Posts: 1815
|
|
...But roll won't change the year! From the documentation
Example: Consider a GregorianCalendar originally set to August 31, 1999. Calling roll(Calendar.MONTH, 8) sets the calendar to April 30, 1999. Using a GregorianCalendar, the DAY_OF_MONTH field cannot be 31 in the month April. DAY_OF_MONTH is set to the closest possible value, 30. The YEAR field maintains the value of 1999 because it is a larger field than MONTH.
[ July 09, 2003: Message edited by: Joel McNary ]
|
 |
sam davis
Greenhorn
Joined: Jun 16, 2003
Posts: 18
|
|
Hey Joel, You are right..I'm sorry but i don't think i was clear about my response..i was talking about changing month...thats what i used roll() for..
|
 |
 |
|
|
subject: Date for last month
|
|
|