If you do not want to do line substitution, and use Java 8 javax.time :
Map<Long, String> ampm = new HashMap<>(); ampm.put(0l, "am"); ampm.put(1l, "pm"); DateTimeFormatter dtf = new DateTimeFormatterBuilder() .appendPattern("EM/dh:mm") .appendText(ChronoField.AMPM_OF_DAY, ampm) .toFormatter() .withZone(ZoneId.of("America/Los_Angeles"));
You must manually build a DateTimeFormatter (specifying the individual parts), since there is no template character for the lowercase letters am / pm. You can use appendPattern before and after.
I believe that there is no way to replace the default characters am / pm, as this is the only way to do a line replacement in the last line.
Nikola Mihajlović Feb 26 '17 at 8:41 2017-02-26 08:41
source share