Swann
Swann

Reputation: 2473

Java parse date using SimpleDateFormat

I am trying to convert a English date from String format to Date and if possible get it as French format.

For example I get something in this format : "2014-07-21T14:31:08+0200" I am using this line but this raise a ParseException any idea ?

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.Z");

Upvotes: 0

Views: 45

Answers (1)

TheConstructor
TheConstructor

Reputation: 4465

You have a . in front of the Z inside the format.

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    Date date = simpleDateFormat.parse("2014-07-21T14:31:08+0200");

happily parses.

Upvotes: 3

Related Questions