Directory

Time Column Renderers - Vaadin Add-on Directory

Vaadin Grid column renderers to display java.time types: `Instant`, `OffsetDateTime`, and `ZonedDateTime` Time Column Renderers - Vaadin Add-on Directory
Time Column Renderers is a non-visual component add-on for [Vaadin Framework](https://vaadin.com/framework) 8.1 and later for displaying additional [java.time](https://docs.oracle.com/javase/9/docs/api/java/time/package-summary.html) types. [Vaadin Grid](https://vaadin.com/docs/v8/framework/components/components-grid.html) 8.1 and later comes bundled with a pair of column renderers for displaying two of the modern date-time data types found in Java 8 and later: - `LocalDateRenderer` for displaying [`LocalDate`](https://docs.oracle.com/javase/9/docs/api/java/time/LocalDate.html) objects - `LocalDateTimeRenderer` for displaying [`LocalDateTime`](https://docs.oracle.com/javase/9/docs/api/java/time/LocalDateTime.html) objects. These two java.time types purposely lack any concept of time zone or offset-from-UTC. The java.time classes include three more types that *do* include a time zone or offset-from-UTC: - [`Instant`](https://docs.oracle.com/javase/9/docs/api/java/time/Instant.html) - [`OffsetDateTime`](https://docs.oracle.com/javase/9/docs/api/java/time/OffsetDateTime.html) - [`ZonedDateTime`](https://docs.oracle.com/javase/9/docs/api/java/time/ZonedDateTime.html) By default, Vaadin Grid calls the `toString` method on such objects to render a String for display. That `toString` method generates a string in standard [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format such as `2017-01-23T01:23:45.678Z`. To display the date-time values in other formats, use this add-on with its trio of column renderers appropriately named: `InstantRenderer`, `OffsetDateTimeRenderer`, and `ZonedDateTimeRenderer`. Specify a [`DateTimeFormatter`](https://docs.oracle.com/javase/9/docs/api/java/time/format/DateTimeFormatter.html) with [`ZoneId`](https://docs.oracle.com/javase/9/docs/api/java/time/ZoneId.html) and [`Locale`](https://docs.oracle.com/javase/9/docs/api/java/util/Locale.html) to adjust zones and localize. The API of these renderer classes follows the pattern of the API of the classes published by Vaadin Ltd. Note that I do not agree with their decision to provide constructors taking a String representing a custom formatting pattern. Other constructors take a `DateTimeFormatter` object, and that should suffice. The column renderers should not, in my opinion, get involved in processing a calling programmer’s custom formatting pattern codes. And these extra constructors complicate the API of these classes with no added benefit. See [my feature request # 10,207](https://github.com/vaadin/framework/issues/10207) to remove these constructors from their API. If deprecated there, I will do so here. Hopefully, such classes as these renderers will be added to Vaadin itself in a future update. See [feature request # 10,208](https://github.com/vaadin/framework/issues/10208).