manuel mourato manuel mourato - 6 months ago 21
Java Question

Unparseable date: " 2014-05-22 09:09:04.145

This may be an extremely simple typo that I have in my code, but I just can't make it work no matter what I do.

I have the following code:

String date="2014-05-22";
String time="09:09:04.145"

String dateAndTime=date.concat(" "+ time);

DateFormat convertDate=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SSSZ");
Date dateOfMeasurement=convertDate.parse(dateAndTime);

I have tried using
yyyy-MM-dd HH:mm:ss:SSS
for the formatting, but nothing works.

What am I doing wrong?
Thank you very much.

 DateFormat convertDate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
 Date dateOfMeasurement=convertDate.parse(dateAndTime);