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
Asked
Active
Viewed 670 times
2 Answers
1
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);

Ke Di
- 345
- 1
- 12
-
I am getting TIME value from server – ABCD Jun 30 '15 at 09:39
0
Hope this might help
String str = "08:03:10 pm";
DateFormat formatter = new SimpleDateFormat("hh:mm:ss a");
Date date = (Date)formatter.parse(str);
or
try {
SimpleDateFormat format = new SimpleDateFormat("hh:mm a"); //if 24 hour format
// or
SimpleDateFormat format = new SimpleDateFormat("HH:mm"); // 12 hour format
java.util.Date d1 =(java.util.Date)format.parse(your_Time);
java.sql.Time ppstime = new java.sql.Time(d1.getTime());
} catch(Exception e) {
Log.e("Exception is ", e.toString());
}

Chathura Jayanath
- 619
- 8
- 13