Klasse DateTimeFormatterService
java.lang.Object
org.apache.turbine.services.BaseInitable
org.apache.turbine.services.BaseService
org.apache.turbine.services.TurbineBaseService
org.apache.turbine.services.localization.DateTimeFormatterService
- Alle implementierten Schnittstellen:
Initable
,DateTimeFormatterInterface
,Service
public class DateTimeFormatterService
extends TurbineBaseService
implements DateTimeFormatterInterface
This service is used to format
TemporalAccessor
and
map(String, DateTimeFormatter, Locale)
(different flavors)
objects into strings.
The methods may throw UnsupportedTemporalTypeException
or
DateTimeParseException
, e.g.
if the source and the target format do not match appropriately.-
Feldübersicht
Von Klasse geerbte Felder org.apache.turbine.services.BaseService
configuration, name, serviceBroker
Von Klasse geerbte Felder org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
Von Schnittstelle geerbte Felder org.apache.turbine.services.localization.DateTimeFormatterInterface
DATE_TIME_FORMAT_DEFAULT, DATE_TIME_FORMAT_KEY, DATE_TIME_ZONEID_KEY, USE_REQUEST_LOCALE_KEY, USE_TURBINE_LOCALE_KEY
Von Schnittstelle geerbte Felder org.apache.turbine.services.Service
SERVICE_NAME
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibung<T extends TemporalAccessor>
Stringformat
(T temporalAccessor) Formats the given datetime as a String with the #getDefaultFormat()
.<T extends TemporalAccessor>
StringFormats the given date as a String.<T extends TemporalAccessor>
StringFormats the given date as a String.<T extends TemporalAccessor>
StringFormats the given date as a String.void
init()
Initialize the service.Maps from an incoming format to an outgoing formatDateTimeFormatter
.map
(String src, DateTimeFormatter outgoingFormat, Locale locale) Uses as incomingDateTimeFormatter
DateTimeFormatterInterface.getDefaultFormat()
.map
(String src, DateTimeFormatter outgoingFormat, Locale locale, DateTimeFormatter incomingFormat) Uses as incoming formatDateTimeFormatterInterface.getDefaultFormat()
and no locale.mapFrom
(String src, DateTimeFormatter incomingFormat) mapTo
(String src, DateTimeFormatter outgoingFormat) Uses as outgoingDateTimeFormatter
DateTimeFormatterInterface.getDefaultFormat()
and no locale.void
void
Von Klasse geerbte Methoden org.apache.turbine.services.TurbineBaseService
init, init, shutdown
Von Klasse geerbte Methoden org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
Von Klasse geerbte Methoden org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
Von Klasse geerbte Methoden java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Von Schnittstelle geerbte Methoden org.apache.turbine.services.Initable
getInit, setInitableBroker
-
Konstruktordetails
-
DateTimeFormatterService
public DateTimeFormatterService()
-
-
Methodendetails
-
getDefaultFormat
- Angegeben von:
getDefaultFormat
in SchnittstelleDateTimeFormatterInterface
-
getFormatPattern
- Angegeben von:
getFormatPattern
in SchnittstelleDateTimeFormatterInterface
-
init
Initialize the service. thedateTimeFormat
fromformatPattern
is initialized withLocale
:LocaleUtils.getDefaultLocale()
is used by default. It could be overridden setting #USE_TURBINE_LOCALE_KEY to false, the the default LocaleLocale.getDefault()
is used.ZoneId
: If #DATE_TIME_ZONEID_KEY is set thisZoneId
is used elseZoneId.systemDefault()
.
- Angegeben von:
init
in SchnittstelleInitable
- Setzt außer Kraft:
init
in KlasseTurbineBaseService
-
format
Beschreibung aus Schnittstelle kopiert:DateTimeFormatterInterface
Formats the given datetime as a String with the #getDefaultFormat()
. using the default date format.- Angegeben von:
format
in SchnittstelleDateTimeFormatterInterface
- Parameter:
temporalAccessor
-Ungültige Eingabe: "to format"
- Gibt zurück:
- String value of the date
-
format
Beschreibung aus Schnittstelle kopiert:DateTimeFormatterInterface
Formats the given date as a String.- Angegeben von:
format
in SchnittstelleDateTimeFormatterInterface
- Parameter:
temporalAccessor
- TimeDate date to formatdateFormatString
- format string to use. SeeDateTimeFormatter
for details.- Gibt zurück:
- String value of the date
-
format
public <T extends TemporalAccessor> String format(T temporalAccessor, String dateFormatString, Locale locale) Beschreibung aus Schnittstelle kopiert:DateTimeFormatterInterface
Formats the given date as a String.- Angegeben von:
format
in SchnittstelleDateTimeFormatterInterface
- Parameter:
temporalAccessor
- TimeDate date to formatdateFormatString
- format string to use. SeeDateTimeFormatter
for details.locale
- used to loclize the format- Gibt zurück:
- String value of the date
-
format
public <T extends TemporalAccessor> String format(T temporalAccessor, String dateFormatString, Locale locale, ZoneId zoneId) Beschreibung aus Schnittstelle kopiert:DateTimeFormatterInterface
Formats the given date as a String.- Angegeben von:
format
in SchnittstelleDateTimeFormatterInterface
- Parameter:
temporalAccessor
- TimeDate date to formatdateFormatString
- format string to use. SeeDateTimeFormatter
for details.locale
- theLocale
zoneId
- theZoneId
- Gibt zurück:
- String value of the date
-
map
public String map(String src, String outgoingFormatPattern, Locale locale, String incomingFormatPattern) Beschreibung aus Schnittstelle kopiert:DateTimeFormatterInterface
Maps from an incoming format to an outgoing formatDateTimeFormatter
.- Angegeben von:
map
in SchnittstelleDateTimeFormatterInterface
- Parameter:
src
- the formatted datetimeoutgoingFormatPattern
- the outgoingFormat pattern,DateTimeFormatter
locale
- Locale, if needed for outgoing formatting, no default.incomingFormatPattern
- the incming format patternDateTimeFormatter
, optional, default isDateTimeFormatterInterface.getDefaultFormat()
.- Gibt zurück:
- the newly mapped
-
map
public String map(String src, DateTimeFormatter outgoingFormat, Locale locale, DateTimeFormatter incomingFormat) Beschreibung aus Schnittstelle kopiert:DateTimeFormatterInterface
Uses as incoming formatDateTimeFormatterInterface.getDefaultFormat()
and no locale.- Angegeben von:
map
in SchnittstelleDateTimeFormatterInterface
- Parameter:
src
- the text, which will be parsed using the incomingFormat.outgoingFormat
- the outgoing formatter, which will format.locale
- The locale, if not null which will outgoingFormat use,DateTimeFormatter.withLocale(Locale)
.incomingFormat
- the incoming formatter, which will be parsed.- Gibt zurück:
- the formatted string
-
mapTo
Beschreibung aus Schnittstelle kopiert:DateTimeFormatterInterface
Uses as outgoingDateTimeFormatter
DateTimeFormatterInterface.getDefaultFormat()
and no locale.- Angegeben von:
mapTo
in SchnittstelleDateTimeFormatterInterface
- Parameter:
src
- the datetime formatted stringoutgoingFormat
- the format of this string- Gibt zurück:
- the date time formatted
-
mapFrom
- Angegeben von:
mapFrom
in SchnittstelleDateTimeFormatterInterface
- Parameter:
src
- the datetime formatted stringincomingFormat
- the format to which this incoming string should be formatted.- Gibt zurück:
- the newly formatted date time string
-
map
Beschreibung aus Schnittstelle kopiert:DateTimeFormatterInterface
Uses as incomingDateTimeFormatter
DateTimeFormatterInterface.getDefaultFormat()
.- Angegeben von:
map
in SchnittstelleDateTimeFormatterInterface
- Parameter:
src
- the datetime formatted stringoutgoingFormat
- the format to which this string should be formatted.locale
- The locale, if not null,the incomingFormat will use.- Gibt zurück:
- the newly formatted date time string
-
getLocale
-
setLocale
-
getZoneId
- Angegeben von:
getZoneId
in SchnittstelleDateTimeFormatterInterface
-
setZoneId
-