I am trying to develop an android application, regarding with that I have got some data from server.
Here I need to convert a date which comes in the given format "2013-12-31T15:07:38.6875000-05:00" I need to convert this in to a date object or a calendar object how can we do this?
I have tried with code given below. But it doesn't reach my expectation
String dateString="2013-12-31T15:07:38.6875000-05:00";
Date date = null;
DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm a");
try {
date = df.parse(dateString);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
Your format string doesn't match the date format you are getting. You should use the following format string:
"yyyy-MM-dd'T'HH:mm:ss.SSSX"
SSS is for milliseconds.X is for ISO 8601 timezoneIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With