Wednesday, 20 July 2016

How to parse time to String value in android?





I have time value from server returned as 13:00:45:888 which is returned as TIME value from SAP backend . How can I convert it to 01:00 PM


Answer



You can try the code below.

SimpleDateFormat sdf1 = new SimpleDateFormat("hh:mm a");
SimpleDateFormat sdf2 = new SimpleDateFormat("hh:mm:ss:SSS");

Date serverTime = sdf2.parse(ValueFromServer);
ResultYouWant = sdf1.format(serverTime);

No comments:

Post a Comment