This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes problem in incrementing date 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 » Java in General
Bookmark "problem in incrementing date" Watch "problem in incrementing date" New topic
Author

problem in incrementing date

harsimran kochar
Greenhorn

Joined: Sep 09, 2011
Posts: 14
here is the code


the problem is that it is not incrementing month
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

The format string in line 9 that you are using to create a SimpleDateFormat is wrong. It should be "dd-MM-yyyy". Note that "mm" means minutes; "MM" means months.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

The other issue is that you probably want to use add instead of roll. See javadoc for the difference between the two.
harsimran kochar
Greenhorn

Joined: Sep 09, 2011
Posts: 14
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in incrementing date
 
Similar Threads
Date difference
setting calendar to an arbitrary date
date arithmetic
Date; Previous date, Calendar; Gregorian
weird java dates!!!!