Use SimpleDateFormat to convert from one format to another. Then you can extra the relevant part from that. One way is following:
String server_format = "2013-08-19T14:29Z"; //server comes format ?
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ");
try {
Date date = sdf.parse(server_format);
System.out.println(date);
String your_format = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(date);
String [] splitted = your_format.split(" ");
System.out.println(splitted[1]); //The second part of the splitted string, i.e time
// Now you can set the TextView here
} catch (ParseException e) {
System.out.println(e.toString()); //date format error
}
P.S I haven't tested this code. Hope you get the concept. See How to format a date android? for more.
Another way is to use .split()
using T
as delimiter. Then just remove the Z
part using answers given on Remove all occurrences of char from string and show the result it in TextView
.
Third way can be to replace T
and Z
with " "
( space ) using .replace
function. Then using .split()
you can just split the string using " "
as delimiter. The second element of the array returned will give time to you.