How to convert local time to am / pm time format using JodaTime?

I am very new to Joda api and I have a call like this:

 LocalTime time = new LocalTime("13");

it prints as: 13:00:00.000.

I would like to show it in the following way: 1:00 PM.

How can i achieve this?

Thanks in advance

+4
source share
2 answers

Try the following:

DateTimeFormatter builder = DateTimeFormat.forPattern("hh:mm:ss.SSa");
+1
source

I have done this:

    LocalTime time = new LocalTime("13");    
    DateTimeFormatter fmt = DateTimeFormat.forPattern("h:mm a");
    String str = fmt.print(time);

And got this output for str:

"1:00 PM"
+2
source

All Articles