Reputation: 1786
I have problems with my datetime formater:
private static final DateTimeFormatter DATE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("dd-MM-yyyy hh:mm")
I want a given LocalDateTime
2015-04-12T20:00
to be printed as
12-04-2015 20:00
but my time is always printed as 08:00, how can I solve this problem?
Upvotes: 2
Views: 3808
Reputation: 1154
You need to follow 24 hours format to achieve this. So use HH instead of hh. Here goes the code
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
For more details on different formats for DateTimeFormatter, look here
Upvotes: 1
Reputation: 34608
Use "dd-MM-yyyy HH:mm"
. Lowercase hh
is 12-hour hours, HH
is 24-hour hours.
Please refer to the documentation of DateTimeFormatter
, where there is a list of all formatting and parsing formats.
Upvotes: 5