File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Problem with SimpleDateFormat Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Problem with SimpleDateFormat " Watch "Problem with SimpleDateFormat " New topic
Author

Problem with SimpleDateFormat

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
Hi all
when i run the below code i am getting the unexpected result.



I am getting the below result
2007-10-10
Wed Jan 10 00:00:00 EST 2007

Actually the output in second line should be for the month Oct, i donno why i am getting Jan. Am i missing something.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Your format:

yyyy-MM-DD

is asking for four digits to represent the year, followed by two to represent the month, followed by two to represent the day in the year. Since the tenth day of the year is in January your date becomes a January date. Try dd instead of DD.
[ January 09, 2007: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Problem with SimpleDateFormat
 
Similar Threads
converting string yyyy/MM/dd to java.util.Date
Where does the extra day come from in duration calculation?
Date 01/01/1970 returning non-zero value for time
Total Time duration
Convert Date from one timezone to another