Sunday, 29 September 2013

Converting joda military time to am/pm

Converting joda military time to am/pm

I just started working with joda got it to correctly display my date in
military time but I would rather it be am/pm. Looked it up and it
mentioned hourOfDay which I figured was the HH value so I tried to write a
loop that would break it down into AM/Pm but it never worked out.
DateTime dtf = new DateTime(wikiParsedDate);
if (hourOfDay == 00) {
hourOfDay == 12;
DateTimeFormatter builder = DateTimeFormat.forPattern( "dd-MM-yyyy
HH:mm:ss.SS'AM" );
return builder.print(dtf);
} else if (0 < hourOfDay && hourOfDay < 12) {
DateTimeFormatter builder = DateTimeFormat.forPattern( "dd-MM-yyyy
HH:mm:ss.SS'AM" );
return builder.print(dtf);
} else if (hourOfDay > 12) {
hourOfDay - 12 == hourOfDay;
DateTimeFormatter builder = DateTimeFormat.forPattern( "dd-MM-yyyy
HH:mm:ss.SS'PM" );
return builder.print(dtf);
}
}

No comments:

Post a Comment