aspose file tools*
The moose likes Beginning Java and the fly likes add day to Date using Calendar.add() question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "add day to Date using Calendar.add() question" Watch "add day to Date using Calendar.add() question" New topic
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: 4246
    
    7

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..!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: add day to Date using Calendar.add() question
 
Similar Threads
Java Calendar Dates
date comman
Java Calendar Dates
string to date conversion
oracle date between