| Author |
add day to Date using Calendar.add() question
|
Andreas Markitanis
Greenhorn
Joined: Apr 15, 2010
Posts: 21
|
|
Hi everyone
I have been trying the following:
My question is how can i make it print 01/08/2010?I googled online but couldn't find anything....
anyone can point me in the right direction??
Thank you very much
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3793
|
|
Ah, a common mistake.
Check the SimpleDateFormat docs, and you'll see:
m = Minute in hour
M = Month in year
|
 |
Vinoth Kumar Kannan
Ranch Hand
Joined: Aug 19, 2009
Posts: 276
|
|
Did you try, Calendar's set(int field, int value) method?
That might help.
Set your month to 8 or do a month = month+1.
Just see the APIs, you'll get it for yourself.
|
OCPJP 6
|
 |
Andreas Markitanis
Greenhorn
Joined: Apr 15, 2010
Posts: 21
|
|
Matthew Brown wrote:Ah, a common mistake.
Check the SimpleDateFormat docs, and you'll see:
m = Minute in hour
M = Month in year
ah thanks Matthew! problem solved ;-)
I knew that MM is months but probably didn't realize at the time.
|
 |
Vinoth Kumar Kannan
Ranch Hand
Joined: Aug 19, 2009
Posts: 276
|
|
|
oops...my interpretation of the posted prob was entirely wrong..!
|
 |
 |
|
|
subject: add day to Date using Calendar.add() question
|
|
|