Package org.linkki.util
Class DateFormats
- java.lang.Object
-
- org.linkki.util.DateFormats
-
public final class DateFormats extends Object
A registry for date format patterns that changes some rather unsuitable default patterns provided byDateFormat.getDateInstance(int, Locale)such as the German "dd.MM.yyyy" instead of "dd.MM.yy".The date pattern for a given locale is determined using the following order:
- Registered patterns for the locale
- Registered patterns for the language
- The
short date patternobtained from the JDK - The ISO date pattern
-
-
Field Summary
Fields Modifier and Type Field Description static StringPATTERN_DEstatic StringPATTERN_ENstatic StringPATTERN_EN_GBstatic StringPATTERN_EN_USstatic StringPATTERN_ISO
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetPattern(Locale locale)Returns the date pattern for the given locale.static voidregister(String languageCode, String pattern)Registers the given pattern for the given language.static voidregister(Locale locale, String pattern)Registers the given pattern for the given locale.
-
-
-
Field Detail
-
PATTERN_ISO
public static final String PATTERN_ISO
- See Also:
- Constant Field Values
-
PATTERN_EN
public static final String PATTERN_EN
- See Also:
- Constant Field Values
-
PATTERN_DE
public static final String PATTERN_DE
- See Also:
- Constant Field Values
-
PATTERN_EN_US
public static final String PATTERN_EN_US
- See Also:
- Constant Field Values
-
PATTERN_EN_GB
public static final String PATTERN_EN_GB
- See Also:
- Constant Field Values
-
-
Method Detail
-
register
public static void register(String languageCode, String pattern)
Registers the given pattern for the given language. The language pattern is used as a fallback if no pattern has been explicitly defined for a locale.To register a pattern for a specific locale use
register(Locale, String).- Parameters:
languageCode- a ISO 639 language code, as obtainable fromLocale.getLanguage()pattern- a pattern forDateTimeFormatter
-
register
public static void register(Locale locale, String pattern)
Registers the given pattern for the given locale.To register a pattern for a language use
register(String, String).- Parameters:
locale- the localepattern- a pattern forDateTimeFormatter
-
getPattern
public static String getPattern(Locale locale)
Returns the date pattern for the given locale. It is determined using the following order:- Registered patterns for the locale
- Registered patterns for the language
- The
short date patternobtained from the JDK - The ISO date pattern
-
-