ABC
ABC

Reputation: 4353

ParseException: Unparseable date:

I have timestamp string like "2015-07-13T10:44:58Z" whe I try convert this in date object it always generates the exception

Caused by: java.text.ParseException: Unparseable date: "2015-07-13T10:44:58Z"

Code which I am using for parsing is like that

    DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    Date subscriptionDate = format.parse("2015-07-13T10:44:58Z");

I don't know what I am doing wrong.

Upvotes: 1

Views: 979

Answers (2)

Andrii Polunin
Andrii Polunin

Reputation: 1306

Your input is inconsistent with your pattern: pattern has millisecond information (.SSS) while input does not (it ends with seconds followed by 'Z'). So you should either provide milliseconds in your input or remove .SSS from date pattern

Upvotes: 1

maja
maja

Reputation: 18034

The patterm SSS stands for Millisecond - which means that your input needs to have 3 decimal places after the second - see here.

Your input, however, has no millisecond information. You have to remove the SSS or add the digits manually (.000).

Upvotes: 2

Related Questions