hoodwink.d enhanced
 

juretta.com

Java SimpleDateFormat: Don't forget to specify the locale | March 07, 2006-->

March 07, 2006

Assuming your current locale is non US the following piece of code will throw a ParseException: Unparseable date: "06-Mar-2006 12:35"

SimpleDateFormat format = new SimpleDateFormat("dd-MMM-yyyy HH:mm");
date = format.parse("06-Mar-2006 12:35");

Note to myself: It's important to specify the correct Locale when parsing dates.

SimpleDateFormat format = 
    new SimpleDateFormat("dd-MMM-yyyy HH:mm", Locale.US);
date = format.parse("06-Mar-2006 12:35");

[1]: http://java.sun.com/.../Locale.html

@11:57 | Comments: 0 | Tags: Dropbox (35), Java (11)

Diggman

About

juretta.com is the personal workspace of Stefan Saasen. You can send him an email or read more about this site in the „About“ section.

« Previous entry

Converting an existing CVS repository...
posted over 2 years ago

» Next entry

Rdoc UTF-8
posted over 2 years ago

Recent comment

On: “Attachr.com: OpenID support added

You need to kill this spam stuff!

posted about 1 year ago by entropie

Look!

Latest links  RSS  

More...