APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.time.format

pack-priv Class DateTimeTextProvider

extends Object
Class Inheritance
Static Imports
java.time.temporal.ChronoField.AMPM_OF_DAY, .ChronoField.DAY_OF_WEEK, .ChronoField.ERA, .ChronoField.MONTH_OF_YEAR

A provider to obtain the textual form of a date-time field.

Implementation Specification

Implementations must be thread-safe. Implementations should cache the textual information.

Since
1.8

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
DateTimeTextProvider.LocaleStore

Stores the text for a single locale.

Field Summary

Modifier and TypeField and Description
private static final ConcurrentMap<Map.Entry<TemporalField, Locale>, Object>
CACHE

Cache.

private static final Comparator<Map.Entry<String, Long>>
COMPARATOR

Comparator.

private static final DateTimeTextProvider

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static <A, B> Map.Entry<A, B>

Returns:

the entry, not null
createEntry
(A
the text, not null
text
,
B
the field, not null
field
)

Helper method to create an immutable entry.

private Object
private Object
pack-priv static DateTimeTextProvider

Returns:

the provider, not null
getInstance
()

Gets the provider of text.

pack-priv static <T> T

Returns:

the localized resource, or null if not available
getLocalizedResource
(String
the key of the localized resource, not null
key
,
Locale
the locale, not null
locale
)

Returns the localized resource of the given key and locale, or null if no localized resource is available.

public String

Returns:

the text for the field value, null if no text found
getText
(TemporalField
the field to get text for, not null
field
,
long
the field value to get text for, not null
value
,
TextStyle
the style to get text for, not null
style
,
Locale
the locale to get text for, not null
locale
)

Gets the text for the specified field, locale and style for the purpose of formatting.

public String

Returns:

the text for the field value, null if no text found
getText
(Chronology
the Chronology to get text for, not null
chrono
,
TemporalField
the field to get text for, not null
field
,
long
the field value to get text for, not null
value
,
TextStyle
the style to get text for, not null
style
,
Locale
the locale to get text for, not null
locale
)

Gets the text for the specified chrono, field, locale and style for the purpose of formatting.

public Iterator<Map.Entry<String, Long>>

Returns:

the iterator of text to field pairs, in order from longest text to shortest text, null if the field or style is not parsable
getTextIterator
(TemporalField
the field to get text for, not null
field
,
TextStyle
the style to get text for, null for all parsable text
style
,
Locale
the locale to get text for, not null
locale
)

Gets an iterator of text to field for the specified field, locale and style for the purpose of parsing.

public Iterator<Map.Entry<String, Long>>

Returns:

the iterator of text to field pairs, in order from longest text to shortest text, null if the field or style is not parsable
getTextIterator
(Chronology
the Chronology to get text for, not null
chrono
,
TemporalField
the field to get text for, not null
field
,
TextStyle
the style to get text for, null for all parsable text
style
,
Locale
the locale to get text for, not null
locale
)

Gets an iterator of text to field for the specified chrono, field, locale and style for the purpose of parsing.

private static int
toWeekDay(int calWeekDay)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CACHEback to summary
private static final ConcurrentMap<Map.Entry<TemporalField, Locale>, Object> CACHE

Cache.

COMPARATORback to summary
private static final Comparator<Map.Entry<String, Long>> COMPARATOR

Comparator.

INSTANCEback to summary
private static final DateTimeTextProvider INSTANCE

Constructor Detail

DateTimeTextProviderback to summary
pack-priv DateTimeTextProvider()

Method Detail

createEntryback to summary
private static <A, B> Map.Entry<A, B> createEntry(A text, B field)

Helper method to create an immutable entry.

Parameters
text:A

the text, not null

field:B

the field, not null

Returns:Map.Entry<A, B>

the entry, not null

createStoreback to summary
private Object createStore(TemporalField field, Locale locale)
findStoreback to summary
private Object findStore(TemporalField field, Locale locale)
getInstanceback to summary
pack-priv static DateTimeTextProvider getInstance()

Gets the provider of text.

Returns:DateTimeTextProvider

the provider, not null

getLocalizedResourceback to summary
pack-priv static <T> T getLocalizedResource(String key, Locale locale)

Returns the localized resource of the given key and locale, or null if no localized resource is available.

Parameters
key:String

the key of the localized resource, not null

locale:Locale

the locale, not null

Returns:T

the localized resource, or null if not available

Annotations
@SuppressWarnings:unchecked
Exceptions
NullPointerException:
if key or locale is null
getTextback to summary
public String getText(TemporalField field, long value, TextStyle style, Locale locale)

Gets the text for the specified field, locale and style for the purpose of formatting.

The text associated with the value is returned. The null return value should be used if there is no applicable text, or if the text would be a numeric representation of the value.

Parameters
field:TemporalField

the field to get text for, not null

value:long

the field value to get text for, not null

style:TextStyle

the style to get text for, not null

locale:Locale

the locale to get text for, not null

Returns:String

the text for the field value, null if no text found

getTextback to summary
public String getText(Chronology chrono, TemporalField field, long value, TextStyle style, Locale locale)

Gets the text for the specified chrono, field, locale and style for the purpose of formatting.

The text associated with the value is returned. The null return value should be used if there is no applicable text, or if the text would be a numeric representation of the value.

Parameters
chrono:Chronology

the Chronology to get text for, not null

field:TemporalField

the field to get text for, not null

value:long

the field value to get text for, not null

style:TextStyle

the style to get text for, not null

locale:Locale

the locale to get text for, not null

Returns:String

the text for the field value, null if no text found

getTextIteratorback to summary
public Iterator<Map.Entry<String, Long>> getTextIterator(TemporalField field, TextStyle style, Locale locale)

Gets an iterator of text to field for the specified field, locale and style for the purpose of parsing.

The iterator must be returned in order from the longest text to the shortest.

The null return value should be used if there is no applicable parsable text, or if the text would be a numeric representation of the value. Text can only be parsed if all the values for that field-style-locale combination are unique.

Parameters
field:TemporalField

the field to get text for, not null

style:TextStyle

the style to get text for, null for all parsable text

locale:Locale

the locale to get text for, not null

Returns:Iterator<Map.Entry<String, Long>>

the iterator of text to field pairs, in order from longest text to shortest text, null if the field or style is not parsable

getTextIteratorback to summary
public Iterator<Map.Entry<String, Long>> getTextIterator(Chronology chrono, TemporalField field, TextStyle style, Locale locale)

Gets an iterator of text to field for the specified chrono, field, locale and style for the purpose of parsing.

The iterator must be returned in order from the longest text to the shortest.

The null return value should be used if there is no applicable parsable text, or if the text would be a numeric representation of the value. Text can only be parsed if all the values for that field-style-locale combination are unique.

Parameters
chrono:Chronology

the Chronology to get text for, not null

field:TemporalField

the field to get text for, not null

style:TextStyle

the style to get text for, null for all parsable text

locale:Locale

the locale to get text for, not null

Returns:Iterator<Map.Entry<String, Long>>

the iterator of text to field pairs, in order from longest text to shortest text, null if the field or style is not parsable

toWeekDayback to summary
private static int toWeekDay(int calWeekDay)
java.time.format back to summary

pack-priv final Class DateTimeTextProvider.LocaleStore

extends Object
Class Inheritance

Stores the text for a single locale.

Some fields have a textual representation, such as day-of-week or month-of-year. These textual representations can be captured in this class for printing and parsing.

This class is immutable and thread-safe.

Field Summary

Modifier and TypeField and Description
private final Map<TextStyle, List<Map.Entry<String, Long>>>
parsable

Parsable data.

private final Map<TextStyle, Map<Long, String>>
valueTextMap

Map of value to text.

Constructor Summary

AccessConstructor and Description
pack-priv
LocaleStore(Map<TextStyle, Map<Long, String>>
the map of values to text to store, assigned and not altered, not null
valueTextMap
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv String

Returns:

the text for the field value, null if no text found
getText
(long
the value to get text for, not null
value
,
TextStyle
the style to get text for, not null
style
)

Gets the text for the specified field value, locale and style for the purpose of printing.

pack-priv Iterator<Map.Entry<String, Long>>

Returns:

the iterator of text to field pairs, in order from longest text to shortest text, null if the style is not parsable
getTextIterator
(TextStyle
the style to get text for, null for all parsable text
style
)

Gets an iterator of text to field for the specified style for the purpose of parsing.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

parsableback to summary
private final Map<TextStyle, List<Map.Entry<String, Long>>> parsable

Parsable data.

valueTextMapback to summary
private final Map<TextStyle, Map<Long, String>> valueTextMap

Map of value to text.

Constructor Detail

LocaleStoreback to summary
pack-priv LocaleStore(Map<TextStyle, Map<Long, String>> valueTextMap)

Constructor.

Parameters
valueTextMap:Map<TextStyle, Map<Long, String>>

the map of values to text to store, assigned and not altered, not null

Method Detail

getTextback to summary
pack-priv String getText(long value, TextStyle style)

Gets the text for the specified field value, locale and style for the purpose of printing.

Parameters
value:long

the value to get text for, not null

style:TextStyle

the style to get text for, not null

Returns:String

the text for the field value, null if no text found

getTextIteratorback to summary
pack-priv Iterator<Map.Entry<String, Long>> getTextIterator(TextStyle style)

Gets an iterator of text to field for the specified style for the purpose of parsing.

The iterator must be returned in order from the longest text to the shortest.

Parameters
style:TextStyle

the style to get text for, null for all parsable text

Returns:Iterator<Map.Entry<String, Long>>

the iterator of text to field pairs, in order from longest text to shortest text, null if the style is not parsable