views:

122

answers:

2

Hello,

I am having a date/time value as 2010-07-26T11:37:52Z , now i wants date in 26-jul-2010 (dd-mon-yyyy) format, how do i do it?

+1  A: 

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

McStretch
+4  A: 

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.

locka
@locka its working perfectly....eally thankful to you for your quick answer, made my life
PM - Paresh Mayani