Quick question, SimpleDateFormat is not performing as I would expect. I am looking to get a date string that look like Thursday 29 November 13:43.
Here is my format:
Calendar c = Calendar.getInstance();
_clockDateFormat = new SimpleDateFormat("cccc dd MMMM kk:mm");
_clockDateFormat.format(c.getTime());
Here is the output:
5 29 11 13:43
What am I doing wrong?
Instead of c use E:
Calendar c = Calendar.getInstance();
SimpleDateFormat _clockDateFormat = new SimpleDateFormat("EEEE dd MMMM kk:mm");
System.out.println(_clockDateFormat.format(c.getTime()));
output:
Thursday 29 November 14:05
See the documentation for more info.
Turns out the device I am working with doesn't have a default locale when it gets here from the factory. As a workaround I used the Locale specific overload for SimpleDateFormat:
_clockDateFormat = new SimpleDateFormat("EEEE dd MMMM HH:mm", Locale.US);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With