Dates & Nulls - part 2

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Dates & Nulls - part 2

bigal.nz
This post was updated on .
Hello,

I am still having issues with dates in a th:each for a table. I find that if all my data has a date in it, it works. It I set one of the dates to null it fails with:

Error formatting date with format pattern "yyyy-MM-dd HH:mm" (plandashboard:112)

The fact that it fails when I introduce a null to me suggests it is the null that is the problem? I thought tx:text was null safe?

My code is:

tr th:each = "plan : ${plan}"
a th:text="${plan.id}" th:href="@{'/plan/' +${plan.id}}"
td th:text="${#dates.format(plan?.planCreationDate, 'yyyy-MM-dd HH:mm')}"

In another effort to be null safe I also tried:

tr th:each = "plan : ${plan}"
td a th:text="${plan.id}" th:href="@{'/plan/' +${plan.id}}">78</td
td span th:if="${date != null}"
         th:text="${#dates.format(plan?.planCreationDate, 'yyyy-MM-dd HH:mm')}"  /span
/td

This method didn't produce an error but just made the whole colum of dates blank.

Any ideas anyone?

TIA

Al
Could someone also please tell me what the secret is for posting html in the forums?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dates & Nulls - part 2

bigal.nz
For anyone else having this issue I had tp update Springboot to use Thymeleaf 3 which handles nulls differently to 2.
Loading...