After formatting a datetime, the time displays AM or PM in upper case, but I want it in lower case like am or pm.
This is my code:
public class Timeis {
public static void main(String s[]) {
long ts = 1022895271767L;
String st = null;
st = new SimpleDateFormat(" MMM d 'at' hh:mm a").format(ts);
System.out.println("time is " + ts);
}
}
st.toLowerCase()
will do it and there is no easier way. – InvertebrateSimpleDateFormat
andDate
. Those classes are poorly designed and long outdated, the former in particular notoriously troublesome. Instead useInstant
,ZoneId
ZonedDateTime
andDateTimeFormatter
, all from java.time, the modern Java date and time API. – Niersteiner