Thymeleaf is an engine designed to create dynamic templates for Java-based applications. The engine provides many utility methods that can be used to build awesome websites. In this article, we will focus on Thymeleaf utility methods for
java.util.Date objects used to present formatted dates and print specific date properties. The implementation of
Date utility methods can be found in the official Thymeleaf GitHub Repository.
2. Available utility methods for
Thymeleaf provides several methods to format java.util.Date objects into a human-readable form. We can also create a new instance by providing date components.
||Format date with the standard locale format||Also works with arrays, lists or sets|
||Format date with the ISO8601 format||Also works with arrays, lists or sets|
||Format date with the specified pattern||Also works with arrays, lists or sets|
||Obtain date properties|
||Create date (java.util.Date) objects from its components|
||Create a date (java.util.Date) object for the current date and time|
||Create a date (java.util.Date) object for the current date (time set to 00:00)|
In this article, we presented Thymeleaf utility methods for
java.util.Date objects. Formatting dates is one of the main use cases that web developers have to struggle with. This utility can ease the pain. You can use it to format date objects, get specific attributes, display the current date, and create date object using its components.