This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Change line 16 to:
cal.set(Calendar.MONTH, lastMonthInt - 1);
Months in Calendar starts with 0 for January - if you set month to 3, Calendar teats this value as April.
You also can use:
cal.roll(Calendar.MONTH, - 1);
Joined: Dec 09, 2006
Thank you so much for the response... I think you didn't understand my question. I know how to manipulate date and time using the Calendar class but how do I set the changed date and / or time into a Date object?
I know this, on line 5, I am getting the time like this:
I am not seeking to get the current time, use the Calendar class to manipulate the current time's data, and set it as a String (the SimpleDateFormat is already in there so I can print to console what the values are).
What I am seeking is to get the current time, use the Calendar class to change the current date's values (specifically month and day) and store in back into a Date object.