SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
David Newton wrote:Jodatime is easier.
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
W. Joe Smith wrote:To start, I would look at the documentaiton for the Calendar class and see what it provides. From there you should be able to get a good start.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:
The getFirstDayOfWeek() should definitely help you out.
public int getFirstDayOfWeek()
Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.
Edward Chen wrote:As advised, I am using Calendar, but it doesn't work for me.
I roll back six months, but it will show up "12/17/2009". How to fix it ?
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
|SCJP-87|SCWCD-95|
|SCJP-87|SCWCD-95|
W. Joe Smith wrote:I believe that subtracting months doesn't have any effect on years. I think your best bet would be to write a small check to see if the number of months being subtracted (or added) would push into a different year, then adjust the year accordingly.
Edgar Balderas wrote:I made a little snippet that do what you need:
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:What happens if --day becomes 0, or ++day overflows to the next year (366 / 367)?
instead of using Calendar.setTimeInMillis(long) works great also.Rob Prime wrote:Use cal.add(Calendar.DAY_OF_YEAR, -1) and cal.add(Calendar.DAY_OF_YEAR, 1) instead of setting the day of year.
|SCJP-87|SCWCD-95|
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Consider Paul's rocket mass heater. |