Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SimpleDateFormat Problem

800343Oct 25 2009 — edited Oct 25 2009
Hi

I ran into a strange error today with SimpleDateFormat .

In the following code:
SimpleDateFormat format =
            new SimpleDateFormat("yyyyMMddHHmmss");
		format.setLenient(false);
		try 
		{
			Date date = format.parse("19850414000000");
		} 
		catch (ParseException e) 
		{
			e.printStackTrace();
		}
I receive an exception:
java.text.ParseException: Unparseable date: "19850414000001"
at java.text.DateFormat.parse(Unknown Source)
at test.MainClass.main(MainClass.java:101)

Could someone please tell me whats wrong with the date: 19850414000001 ?
Actually after checking some more, all the times between 19850414000000 and 19850414005959 give this error while for example 19850414010000 or 19850413235959 work fine.
Also this only happens for setLenient(false).

What happened on the 14th of april 1985 that the Parser doesn't want to talk about?

Thanks
Aharon
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 22 2009
Added on Oct 25 2009
10 comments
528 views