The date strings comes from XML feed to my app in format like this Mon, 10 Dec 2012 13:18:23 GMT and I would like to format is as “13:18:23”. I have this method
private String formatTime(String time) {
DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss zzz", Locale.getDefault());
String temp = null;
try {
temp = df.format(time);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return temp;
}
but I keep getting error IllegalArgumentException.
Anyone can see that is going on with this code?
Output:
Converted date is : 15:18:23You have difference +2 hours because of GMT. Remove
zzzfromDATE_FORMATand you get:13:18:23