thymeleaf / thymeleaf-extras-java8time

Thymeleaf "extras" dialect for formatting and creating Java 8 Time API objects
Apache License 2.0
105 stars 34 forks source link

Could not localize LocalDateTime from java 8. #15

Closed uladkaminski closed 5 years ago

uladkaminski commented 7 years ago

During this operation

${#temporals.format(ticket.getDateTime(), #locale)}

there is an issue:

java.lang.IllegalArgumentException: Unknown pattern letter: U at java.time.format.DateTimeFormatterBuilder.parsePattern(DateTimeFormatterBuilder.java:1661) ~[na:1.8.0_131] at java.time.format.DateTimeFormatterBuilder.appendPattern(DateTimeFormatterBuilder.java:1570) ~[na:1.8.0_131] at java.time.format.DateTimeFormatter.ofPattern(DateTimeFormatter.java:560) ~[na:1.8.0_131]

jmiguelsamper commented 5 years ago

First of all, my apologies for this extremely late reply.

By the stack trace included in the report, it seems that the #locale argument is interpreted as an String.

However, I've tested the following expressions:

  <p th:text="${#locale}">locale</p>
  <p th:text="${#locale.getClass().getName()}">locale class</p>
  <p th:text="${#temporals.format(#temporals.createNow(), #locale)}">time</p>

and got the expected results:

en_GB
java.util.Locale
24 November 2018, 22:00:52

If anyone encounters a similar issue, please include the type of the time class used (ticket.getDateTime() in the previous report) and the value of the locale argument.