I want to convert this date format :
2014-04-23T14:20:00.000-07:00
into a date object so I can use this method to get the difference :
DateUtils.getDateDifference(DATE_OBJECT);
...
I've tried using 'SimpleDateFormat' but it throws an exception, checked the code many times, but doesn't work:
String pubDate = "2014-04-23T14:20:00.000-07:00";
SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss Z", Locale.ENGLISH);
try {
Date pDate = df.parse(pubDate);
pubDate = "This post was published " + DateUtils.getDateDifference(pDate);
} catch (ParseException e) {
Log.e("DATE PARSING", "Error parsing date..");
pubDate = "Couldn't be retrieved.";
}
What is the simplest way to achieve it successfully?