I am trying to parse String into a Date object using SimpleDateFormat. Below is my code
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm.sss");
Date parsedDate = formatter.parse("2016-06-28T14:10:23.374Z");
System.out.println(parsedDate.toString());
This is giving me below exception
Exception in thread "main" java.text.ParseException: Unparseable date: "2016-06-28T14:10:23.374Z"
at java.text.DateFormat.parse(DateFormat.java:368)
at com.bac.rds.dolphin.test.Main.main(Main.java:60)
My understanding of the problem is that the Format String I am using in SDF may not be appropriate.I am not much familiar with SimpleDateFormat any help to get this working is appreciated.
EDIT
Have updated my format String as below
yyyy-MM-dd'T'HH:mm:ss.SSS
This format string is able to parse the String into date object . But when I try to include Z at the end of the format string inorder to specify the timezone as the Z is there also in the Date String I have . It gives parse exception .
Below is the format throwing parse exception
yyyy-MM-dd'T'HH:mm:ss.SSSZ
Why this behavior?