I just started working with Joda-Time and got the correct display of my date in 24-hour format ("wartime"), but I would rather be am / pm. He looked, and he mentioned hourOfDay , which, as I understand it, was an HH value, so I tried to write a loop that would break it into AM / Pm, but that did not work.
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); } }
source share