Why is Thymeleaf dealing better with Calendar objects than rather with java.util.Date objects

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why is Thymeleaf dealing better with Calendar objects than rather with java.util.Date objects

frandevel
In our case, our persistent objects which we at the end display in the views (or DTO's from this and another object) have been always using java.util.Date objects for persisting dates or timestamps.
Now we find that in Thymeleaf, all is about Calendar objects when you need to format dates in the view:
i.e:

format(calendarObject, 'EEE dd MM yyyy') so would we have to do a conversion first in the controllers or register a custom property editor for this?

What is the goal for using Calendar objects apart from having a richer set of methods to get the day of the week, the hour of the day and so?

Thanks in advance,

Fran
Reply | Threaded
Open this post in threaded view
|

Re: Why is Thymeleaf dealing better with Calendar objects than rather with java.util.Date objects

Zemi
Administrator
There are also methods for formatting dates, see chapter 16 of the "Using Thymeleaf" tutorial at the documentation page.
 
Reply | Threaded
Open this post in threaded view
|

Re: Why is Thymeleaf dealing better with Calendar objects than rather with java.util.Date objects

frandevel
Thanks a lot Zemi and I apologize...

This confirms I was to tired last night when dealing with this. It was in front of me when reading the docs and did not see it anyway.

Maybe I should think about posting to the forum in the morning

Cheers!