Monday, February 5, 2018

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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...