I have a literal string which is " 2015-12-08T13:04:51Z " , which I would like to convert to date format to show : December 08, 2015 3:04:51 pm. But every time I try all the solutions available online my app crashes with a bad date format exception . How do I get it to display the requiredformat. The current code I am using is :
String mydate = ((Search) searchResult).getmydate();
which returns "2015-12-08T13:04:51Z " I tried this:
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
try {
Date date = format.parse(mydate);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
result = date;
But every single time I do that it crashes. Any ides how to go about it in the UTC time zone in the required format?