Monday, 5 February 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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...