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?
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?
Have you tried using Java's SimpleDateFormat
class? It is included with the android SDK: http://developer.android.com/reference/java/text/SimpleDateFormat.html
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.