I am storing time in the database in this format: "hh:mm:ss"
(example- 09:30:00) and then retrieving and trying to show it to users in this format: "hh:mm AM/PM" (example- 09:30 AM).
I'm using below code for converting it:
DateFormat currentTime = new SimpleDateFormat("hh:mm a");
String startTimeInSF = currentTime.format(startTime);
String endTimeInSF = currentTime.format(endTime);
where startTime
and endTime
is in hh:mm:ss
format, but the above code is producing this error: java.lang.IllegalArgumentException: Bad class: class java.lang.String
.
Please let me know how can I successfully convert the time from hh:mm:ss
to hh:mm AM/PM
?