Date format conversion using Java

Construct two SimpleDateFormat objects. The first you parse() the value from into a Date object, the second you use to turn the Date object back into a string, e.g.

try {
  DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
  DateFormat df2 = new SimpleDateFormat("dd-MMM-yyyy");
  return df2.format(df1.parse(input));
}
catch (ParseException e) {
  return null;
}

Parsing can throw a ParseException so you would need to catch and handle that.


Have you tried using Java's SimpleDateFormat class? It is included with the android SDK: http://developer.android.com/reference/java/text/SimpleDateFormat.html