Top Description Inners Fields Constructors Methods
org.apache.commons.lang3.time

pack-priv abstract Class AbstractFormatCache<F extends Format>

extends Object
Class Inheritance
Type Parameters
<F>
The Format type.
Imports
java.text.DateFormat, .Format, .SimpleDateFormat, java.util.Arrays, .Locale, .Objects, .TimeZone, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, org.apache.commons.lang3.LocaleUtils

Caches for Format instances.
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
AbstractFormatCache.ArrayKey

Helper class to hold multipart Map keys as arrays.

Field Summary

Modifier and TypeField and Description
private static final ConcurrentMap<AbstractFormatCache.ArrayKey, String>
private final ConcurrentMap<AbstractFormatCache.ArrayKey, F>
pack-priv static final int
NONE

No date or no time.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
clear()

Clears the cache.

pack-priv void
clearInstance()

Clears the cache.

protected abstract F

Returns:

a pattern based date/time formatter.
createInstance
(String
java.text.SimpleDateFormat compatible pattern, this will not be null.
pattern
,
TimeZone
time zone, this will not be null.
timeZone
,
Locale
locale, this will not be null.
locale
)

Create a format instance using the specified pattern, time zone and locale.

pack-priv F

Returns:

a localized standard date/time formatter.
getDateInstance
(final int
date style: FULL, LONG, MEDIUM, or SHORT.
dateStyle
,
final TimeZone
optional time zone, overrides time zone of formatted date, null means use default Locale.
timeZone
,
final Locale
optional locale, overrides system locale.
locale
)

Gets a date formatter instance using the specified style, time zone and locale.

pack-priv F

Returns:

a localized standard date/time formatter.
getDateTimeInstance
(final int
date style: FULL, LONG, MEDIUM, or SHORT.
dateStyle
,
final int
time style: FULL, LONG, MEDIUM, or SHORT.
timeStyle
,
final TimeZone
optional time zone, overrides time zone of formatted date, null means use default Locale.
timeZone
,
final Locale
optional locale, overrides system locale.
locale
)

Gets a date/time formatter instance using the specified style, time zone and locale.

private F

Returns:

a localized standard date/time formatter.
getDateTimeInstance
(final Integer
date style: FULL, LONG, MEDIUM, or SHORT, null indicates no date in format.
dateStyle
,
final Integer
time style: FULL, LONG, MEDIUM, or SHORT, null indicates no time in format.
timeStyle
,
final TimeZone
optional time zone, overrides time zone of formatted date, null means use default Locale.
timeZone
,
Locale
optional locale, overrides system locale.
locale
)

Gets a date/time formatter instance using the specified style, time zone and locale.

public F

Returns:

a date/time formatter.
getInstance
()

Gets a formatter instance using the default pattern in the default time zone and locale.

public F

Returns:

a pattern based date/time formatter.
getInstance
(final String
java.text.SimpleDateFormat compatible pattern, non-null.
pattern
,
final TimeZone
the time zone, null means use the default TimeZone.
timeZone
,
final Locale
the locale, null means use the default Locale.
locale
)

Gets a formatter instance using the specified pattern, time zone and locale.

pack-priv static String

Returns:

a localized standard date/time format.
getPatternForStyle
(final Integer
date style: FULL, LONG, MEDIUM, or SHORT, null indicates no date in format.
dateStyle
,
final Integer
time style: FULL, LONG, MEDIUM, or SHORT, null indicates no time in format.
timeStyle
,
final Locale
The non-null locale of the desired format.
locale
)

Gets a date/time format for the specified styles and locale.

pack-priv F

Returns:

a localized standard date/time formatter.
getTimeInstance
(final int
time style: FULL, LONG, MEDIUM, or SHORT.
timeStyle
,
final TimeZone
optional time zone, overrides time zone of formatted date, null means use default Locale.
timeZone
,
final Locale
optional locale, overrides system locale.
locale
)

Gets a time formatter instance using the specified style, time zone and locale.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dateTimeInstanceCacheback to summary
private static final ConcurrentMap<AbstractFormatCache.ArrayKey, String> dateTimeInstanceCache
instanceCacheback to summary
private final ConcurrentMap<AbstractFormatCache.ArrayKey, F> instanceCache
NONEback to summary
pack-priv static final int NONE

No date or no time. Used in same parameters as DateFormat.SHORT or DateFormat.LONG.

Constructor Detail

AbstractFormatCacheback to summary
pack-priv AbstractFormatCache()

Method Detail

clearback to summary
pack-priv static void clear()

Clears the cache.

clearInstanceback to summary
pack-priv void clearInstance()

Clears the cache.

createInstanceback to summary
protected abstract F createInstance(String pattern, TimeZone timeZone, Locale locale)

Create a format instance using the specified pattern, time zone and locale.

Parameters
pattern:String

java.text.SimpleDateFormat compatible pattern, this will not be null.

timeZone:TimeZone

time zone, this will not be null.

locale:Locale

locale, this will not be null.

Returns:F

a pattern based date/time formatter.

Exceptions
IllegalArgumentException:
if pattern is invalid or null.
getDateInstanceback to summary
pack-priv F getDateInstance(final int dateStyle, final TimeZone timeZone, final Locale locale)

Gets a date formatter instance using the specified style, time zone and locale.

Parameters
dateStyle:int

date style: FULL, LONG, MEDIUM, or SHORT.

timeZone:TimeZone

optional time zone, overrides time zone of formatted date, null means use default Locale.

locale:Locale

optional locale, overrides system locale.

Returns:F

a localized standard date/time formatter.

Exceptions
IllegalArgumentException:
if the Locale has no date/time pattern defined.
getDateTimeInstanceback to summary
pack-priv F getDateTimeInstance(final int dateStyle, final int timeStyle, final TimeZone timeZone, final Locale locale)

Gets a date/time formatter instance using the specified style, time zone and locale.

Parameters
dateStyle:int

date style: FULL, LONG, MEDIUM, or SHORT.

timeStyle:int

time style: FULL, LONG, MEDIUM, or SHORT.

timeZone:TimeZone

optional time zone, overrides time zone of formatted date, null means use default Locale.

locale:Locale

optional locale, overrides system locale.

Returns:F

a localized standard date/time formatter.

Exceptions
IllegalArgumentException:
if the Locale has no date/time pattern defined.
getDateTimeInstanceback to summary
private F getDateTimeInstance(final Integer dateStyle, final Integer timeStyle, final TimeZone timeZone, Locale locale)

Gets a date/time formatter instance using the specified style, time zone and locale.

Parameters
dateStyle:Integer

date style: FULL, LONG, MEDIUM, or SHORT, null indicates no date in format.

timeStyle:Integer

time style: FULL, LONG, MEDIUM, or SHORT, null indicates no time in format.

timeZone:TimeZone

optional time zone, overrides time zone of formatted date, null means use default Locale.

locale:Locale

optional locale, overrides system locale.

Returns:F

a localized standard date/time formatter.

Exceptions
IllegalArgumentException:
if the Locale has no date/time pattern defined.
getInstanceback to summary
public F getInstance()

Gets a formatter instance using the default pattern in the default time zone and locale.

Returns:F

a date/time formatter.

getInstanceback to summary
public F getInstance(final String pattern, final TimeZone timeZone, final Locale locale)

Gets a formatter instance using the specified pattern, time zone and locale.

Parameters
pattern:String

java.text.SimpleDateFormat compatible pattern, non-null.

timeZone:TimeZone

the time zone, null means use the default TimeZone.

locale:Locale

the locale, null means use the default Locale.

Returns:F

a pattern based date/time formatter.

Exceptions
NullPointerException:
if pattern is null.
IllegalArgumentException:
if pattern is invalid.
getPatternForStyleback to summary
pack-priv static String getPatternForStyle(final Integer dateStyle, final Integer timeStyle, final Locale locale)

Gets a date/time format for the specified styles and locale.

Parameters
dateStyle:Integer

date style: FULL, LONG, MEDIUM, or SHORT, null indicates no date in format.

timeStyle:Integer

time style: FULL, LONG, MEDIUM, or SHORT, null indicates no time in format.

locale:Locale

The non-null locale of the desired format.

Returns:String

a localized standard date/time format.

Exceptions
IllegalArgumentException:
if the Locale has no date/time pattern defined.
getTimeInstanceback to summary
pack-priv F getTimeInstance(final int timeStyle, final TimeZone timeZone, final Locale locale)

Gets a time formatter instance using the specified style, time zone and locale.

Parameters
timeStyle:int

time style: FULL, LONG, MEDIUM, or SHORT.

timeZone:TimeZone

optional time zone, overrides time zone of formatted date, null means use default Locale.

locale:Locale

optional locale, overrides system locale.

Returns:F

a localized standard date/time formatter.

Exceptions
IllegalArgumentException:
if the Locale has no date/time pattern defined.
org.apache.commons.lang3.time back to summary

private final Class AbstractFormatCache.ArrayKey

extends Object
Class Inheritance

Helper class to hold multipart Map keys as arrays.

Field Summary

Modifier and TypeField and Description
private final int
private final Object[]

Constructor Summary

AccessConstructor and Description
pack-priv
ArrayKey(final Object...
the set of objects that make up the key. Each key may be null.
keys
)

Constructs an instance of MultipartKey to hold the specified objects.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

hashCodeback to summary
private final int hashCode
keysback to summary
private final Object[] keys

Constructor Detail

ArrayKeyback to summary
pack-priv ArrayKey(final Object... keys)

Constructs an instance of MultipartKey to hold the specified objects.

Parameters
keys:Object[]

the set of objects that make up the key. Each key may be null.

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override