abstract class FormatCache<F extends java.text.Format>
extends java.lang.Object
FormatCache is a cache and factory for Format
s.
Modifier and Type | Class and Description |
---|---|
private static class |
FormatCache.MultipartKey
Helper class to hold multi-part Map keys
|
Modifier and Type | Field and Description |
---|---|
private static java.util.concurrent.ConcurrentMap<FormatCache.MultipartKey,java.lang.String> |
cDateTimeInstanceCache |
private java.util.concurrent.ConcurrentMap<FormatCache.MultipartKey,F> |
cInstanceCache |
(package private) static int |
NONE
No date or no time.
|
Constructor and Description |
---|
FormatCache() |
Modifier and Type | Method and Description |
---|---|
protected abstract F |
createInstance(java.lang.String pattern,
java.util.TimeZone timeZone,
java.util.Locale locale)
Create a format instance using the specified pattern, time zone
and locale.
|
(package private) F |
getDateInstance(int dateStyle,
java.util.TimeZone timeZone,
java.util.Locale locale)
Gets a date formatter instance using the specified style,
time zone and locale.
|
private F |
getDateTimeInstance(java.lang.Integer dateStyle,
java.lang.Integer timeStyle,
java.util.TimeZone timeZone,
java.util.Locale locale)
Gets a date/time formatter instance using the specified style,
time zone and locale.
|
(package private) F |
getDateTimeInstance(int dateStyle,
int timeStyle,
java.util.TimeZone timeZone,
java.util.Locale locale)
Gets a date/time formatter instance using the specified style,
time zone and locale.
|
F |
getInstance()
Gets a formatter instance using the default pattern in the
default timezone and locale.
|
F |
getInstance(java.lang.String pattern,
java.util.TimeZone timeZone,
java.util.Locale locale)
Gets a formatter instance using the specified pattern, time zone
and locale.
|
(package private) static java.lang.String |
getPatternForStyle(java.lang.Integer dateStyle,
java.lang.Integer timeStyle,
java.util.Locale locale)
Gets a date/time format for the specified styles and locale.
|
(package private) F |
getTimeInstance(int timeStyle,
java.util.TimeZone timeZone,
java.util.Locale locale)
Gets a time formatter instance using the specified style,
time zone and locale.
|
static final int NONE
private final java.util.concurrent.ConcurrentMap<FormatCache.MultipartKey,F extends java.text.Format> cInstanceCache
private static final java.util.concurrent.ConcurrentMap<FormatCache.MultipartKey,java.lang.String> cDateTimeInstanceCache
public F getInstance()
Gets a formatter instance using the default pattern in the default timezone and locale.
public F getInstance(java.lang.String pattern, java.util.TimeZone timeZone, java.util.Locale locale)
Gets a formatter instance using the specified pattern, time zone and locale.
pattern
- SimpleDateFormat
compatible
pattern, non-nulltimeZone
- the time zone, null means use the default TimeZonelocale
- the locale, null means use the default Localejava.lang.IllegalArgumentException
- if pattern is invalid
or null
protected abstract F createInstance(java.lang.String pattern, java.util.TimeZone timeZone, java.util.Locale locale)
Create a format instance using the specified pattern, time zone and locale.
pattern
- SimpleDateFormat
compatible pattern, this will not be null.timeZone
- time zone, this will not be null.locale
- locale, this will not be null.java.lang.IllegalArgumentException
- if pattern is invalid
or null
private F getDateTimeInstance(java.lang.Integer dateStyle, java.lang.Integer timeStyle, java.util.TimeZone timeZone, java.util.Locale locale)
Gets a date/time formatter instance using the specified style, time zone and locale.
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 localejava.lang.IllegalArgumentException
- if the Locale has no date/time
pattern definedF getDateTimeInstance(int dateStyle, int timeStyle, java.util.TimeZone timeZone, java.util.Locale locale)
Gets a date/time formatter instance using the specified style, time zone and locale.
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 localejava.lang.IllegalArgumentException
- if the Locale has no date/time
pattern definedF getDateInstance(int dateStyle, java.util.TimeZone timeZone, java.util.Locale locale)
Gets a date formatter instance using the specified style, time zone and locale.
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 localejava.lang.IllegalArgumentException
- if the Locale has no date/time
pattern definedF getTimeInstance(int timeStyle, java.util.TimeZone timeZone, java.util.Locale locale)
Gets a time formatter instance using the specified style, time zone and locale.
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 localejava.lang.IllegalArgumentException
- if the Locale has no date/time
pattern definedstatic java.lang.String getPatternForStyle(java.lang.Integer dateStyle, java.lang.Integer timeStyle, java.util.Locale locale)
Gets a date/time format for the specified styles and locale.
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 formatjava.lang.IllegalArgumentException
- if the Locale has no date/time pattern defined