File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Android Security Essentials Live Lessons this week in the Android 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: 4343
    
    8

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
 
Similar Threads
string to date conversion
date comman
oracle date between
Java Calendar Dates
Java Calendar Dates