Package org.apache.commons.lang3.time
Class AbstractFormatCache<F extends Format>
java.lang.Object
org.apache.commons.lang3.time.AbstractFormatCache<F>
- Type Parameters:
F- The Format type.
FormatCache is a cache and factory for
Formats.- Since:
- 3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classHelper class to hold multipart Map keys as arrays. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ConcurrentMap<AbstractFormatCache.ArrayKey, String> private final ConcurrentMap<AbstractFormatCache.ArrayKey, F> (package private) static final intNo date or no time. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract FcreateInstance(String pattern, TimeZone timeZone, Locale locale) Create a format instance using the specified pattern, time zone and locale.(package private) FgetDateInstance(int dateStyle, TimeZone timeZone, Locale locale) Gets a date formatter instance using the specified style, time zone and locale.(package private) FgetDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone, Locale locale) Gets a date/time formatter instance using the specified style, time zone and locale.private FgetDateTimeInstance(Integer dateStyle, Integer timeStyle, TimeZone timeZone, Locale locale) Gets a date/time formatter instance using the specified style, time zone and locale.Gets a formatter instance using the default pattern in the default time zone and locale.getInstance(String pattern, TimeZone timeZone, Locale locale) Gets a formatter instance using the specified pattern, time zone and locale.(package private) static StringgetPatternForStyle(Integer dateStyle, Integer timeStyle, Locale locale) Gets a date/time format for the specified styles and locale.(package private) FgetTimeInstance(int timeStyle, TimeZone timeZone, Locale locale) Gets a time formatter instance using the specified style, time zone and locale.
-
Field Details
-
NONE
static final int NONENo date or no time. Used in same parameters as DateFormat.SHORT or DateFormat.LONG- See Also:
-
cDateTimeInstanceCache
-
cInstanceCache
-
-
Constructor Details
-
AbstractFormatCache
AbstractFormatCache()
-
-
Method Details
-
getPatternForStyle
Gets a date/time format for the specified styles and locale.- Parameters:
dateStyle- date style: FULL, LONG, MEDIUM, or SHORT, null indicates no date in formattimeStyle- time style: FULL, LONG, MEDIUM, or SHORT, null indicates no time in formatlocale- The non-null locale of the desired format- Returns:
- a localized standard date/time format
- Throws:
IllegalArgumentException- if the Locale has no date/time pattern defined
-
createInstance
Create a format instance using the specified pattern, time zone and locale.- Parameters:
pattern-SimpleDateFormatcompatible pattern, this will not be null.timeZone- time zone, this will not be null.locale- locale, this will not be null.- Returns:
- a pattern based date/time formatter
- Throws:
IllegalArgumentException- if pattern is invalid ornull
-
getDateInstance
Gets a date formatter instance using the specified style, time zone and locale.- Parameters:
dateStyle- date style: FULL, LONG, MEDIUM, or SHORTtimeZone- optional time zone, overrides time zone of formatted date, null means use default Localelocale- optional locale, overrides system locale- Returns:
- a localized standard date/time formatter
- Throws:
IllegalArgumentException- if the Locale has no date/time pattern defined
-
getDateTimeInstance
Gets a date/time formatter instance using the specified style, time zone and locale.- Parameters:
dateStyle- date style: FULL, LONG, MEDIUM, or SHORTtimeStyle- time style: FULL, LONG, MEDIUM, or SHORTtimeZone- optional time zone, overrides time zone of formatted date, null means use default Localelocale- optional locale, overrides system locale- Returns:
- a localized standard date/time formatter
- Throws:
IllegalArgumentException- if the Locale has no date/time pattern defined
-
getDateTimeInstance
private F getDateTimeInstance(Integer dateStyle, Integer timeStyle, TimeZone timeZone, Locale locale) Gets a date/time formatter instance using the specified style, time zone and locale.- Parameters:
dateStyle- date style: FULL, LONG, MEDIUM, or SHORT, null indicates no date in formattimeStyle- time style: FULL, LONG, MEDIUM, or SHORT, null indicates no time in formattimeZone- optional time zone, overrides time zone of formatted date, null means use default Localelocale- optional locale, overrides system locale- Returns:
- a localized standard date/time formatter
- Throws:
IllegalArgumentException- if the Locale has no date/time pattern defined
-
getInstance
Gets a formatter instance using the default pattern in the default time zone and locale.- Returns:
- a date/time formatter
-
getInstance
Gets a formatter instance using the specified pattern, time zone and locale.- Parameters:
pattern-SimpleDateFormatcompatible pattern, non-nulltimeZone- the time zone, null means use the default TimeZonelocale- the locale, null means use the default Locale- Returns:
- a pattern based date/time formatter
- Throws:
NullPointerException- if pattern isnullIllegalArgumentException- if pattern is invalid
-
getTimeInstance
Gets a time formatter instance using the specified style, time zone and locale.- Parameters:
timeStyle- time style: FULL, LONG, MEDIUM, or SHORTtimeZone- optional time zone, overrides time zone of formatted date, null means use default Localelocale- optional locale, overrides system locale- Returns:
- a localized standard date/time formatter
- Throws:
IllegalArgumentException- if the Locale has no date/time pattern defined
-