Date Formats

The class org.linkki.util.DateFormats is used as the authoritative source for date formats, ensuring consistent formatting throughout the application. UI elements such as @UIDateField or @UILabel automatically use the formats specified there.

Default formats

A few patterns for German and English are registered by default, otherwise patterns specified by the JDK (or ISO if no pattern is available) are used as a fallback.

Locale Pattern









Registering a custom date format

In case the used format is not suitable, a custom date format can be registered to override it. This can be done either for a single locale, or for all locales with the given language (a country-specific registration takes precedence, regardless of the registration order).

Example registration for fr_FR and fr_*
public class PlaygroundApplicationConfig implements ApplicationConfig {

    static {
        // this only applies to fr_FR
        DateFormats.register(Locale.FRANCE, "dd/MM/yy");

        // this applies to other locales with an fr language code, such as fr_CH or fr_BE
        DateFormats.register("fr", "dd/MM/yyyy");

The DateFormats storage is global and session-independant, custom date formats should be registered once at application startup. A static block inside your ApplicationConfig is a possible option.

Manually formatting a date

DateFormats#getPattern(Locale) should be used to stay consistent with the format used in other parts of the application. The returned pattern can be used by the DateTimeFormatter.

Example using the session locale
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateFormats.getPattern(UiFramework.getLocale()));
LocalDate.of(2022, 02, 05).format(formatter);