Class 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
-
- All Implemented Interfaces:
Initable,DateTimeFormatterInterface,Service
public class DateTimeFormatterService extends TurbineBaseService implements DateTimeFormatterInterface
This service is used to formatTemporalAccessorandmap(String, DateTimeFormatter, Locale)(different falvors) objects into strings. The methods may throwUnsupportedTemporalTypeExceptionorDateTimeParseException. if the source and the target format do not match appropriately.
-
-
Field Summary
Fields Modifier and Type Field Description static StringROLEstatic StringSERVICE_NAME-
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, serviceBroker
-
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
-
-
Constructor Summary
Constructors Constructor Description DateTimeFormatterService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends TemporalAccessor>
Stringformat(T temporalAccessor)Formats the given datetime as a String with the #defaultFormat.<T extends TemporalAccessor>
Stringformat(T temporalAccessor, String dateFormatString)Formats the given date as a String.<T extends TemporalAccessor>
Stringformat(T temporalAccessor, String dateFormatString, Locale locale)Formats the given date as a String.StringgetDateTimeFormatPattern()DateTimeFormattergetDefaultFormat()voidinit()Initialize the service.Stringmap(String src, String outgoingFormatPattern, Locale locale, String incomingFormatPattern)Maps from an incoming format to an outgoing formatDateTimeFormatter.Stringmap(String src, DateTimeFormatter outgoingFormat, Locale locale)Stringmap(String src, DateTimeFormatter outgoingFormat, Locale locale, DateTimeFormatter incomingFormat)Uses as incoming format#defaultFormatand no locale.StringmapFrom(String src, DateTimeFormatter incomingFormat)Uses as incomingDateTimeFormatter#defaultFormat.StringmapTo(String src, DateTimeFormatter outgoingFormat)Uses as outgoingDateTimeFormatter#defaultFormatand no locale.-
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init, shutdown
-
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
-
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.turbine.services.Initable
getInit, setInitableBroker
-
-
-
-
Field Detail
-
SERVICE_NAME
public static String SERVICE_NAME
-
-
Constructor Detail
-
DateTimeFormatterService
public DateTimeFormatterService()
-
-
Method Detail
-
getDefaultFormat
public DateTimeFormatter getDefaultFormat()
- Specified by:
getDefaultFormatin interfaceDateTimeFormatterInterface
-
getDateTimeFormatPattern
public String getDateTimeFormatPattern()
- Specified by:
getDateTimeFormatPatternin interfaceDateTimeFormatterInterface
-
init
public void init()
Initialize the service. thedefaultFormatfromdateTimeFormatPatternis initialized with the default LocaleLocale.getDefault()and default zone:ZoneId.systemDefault().- Specified by:
initin interfaceInitable- Overrides:
initin classTurbineBaseService
-
format
public <T extends TemporalAccessor> String format(T temporalAccessor)
Description copied from interface:DateTimeFormatterInterfaceFormats the given datetime as a String with the #defaultFormat. using the default date format.- Specified by:
formatin interfaceDateTimeFormatterInterface- Returns:
- String value of the date
-
format
public <T extends TemporalAccessor> String format(T temporalAccessor, String dateFormatString)
Description copied from interface:DateTimeFormatterInterfaceFormats the given date as a String.- Specified by:
formatin interfaceDateTimeFormatterInterfacedateFormatString- format string to use. SeeDateTimeFormatterfor details.- Returns:
- String value of the date
-
format
public <T extends TemporalAccessor> String format(T temporalAccessor, String dateFormatString, Locale locale)
Description copied from interface:DateTimeFormatterInterfaceFormats the given date as a String.- Specified by:
formatin interfaceDateTimeFormatterInterfacedateFormatString- format string to use. SeeDateTimeFormatterfor details.- Returns:
- String value of the date
-
map
public String map(String src, String outgoingFormatPattern, Locale locale, String incomingFormatPattern)
Description copied from interface:DateTimeFormatterInterfaceMaps from an incoming format to an outgoing formatDateTimeFormatter.- Specified by:
mapin interfaceDateTimeFormatterInterface- Parameters:
src- the formatted datetimelocale- Locale, if needed for outgoing formatting, no default.- Returns:
- the newly mapped
-
map
public String map(String src, DateTimeFormatter outgoingFormat, Locale locale, DateTimeFormatter incomingFormat)
Description copied from interface:DateTimeFormatterInterfaceUses as incoming format#defaultFormatand no locale.- Specified by:
mapin interfaceDateTimeFormatterInterface- Returns:
- the formatted string
-
mapTo
public String mapTo(String src, DateTimeFormatter outgoingFormat)
Description copied from interface:DateTimeFormatterInterfaceUses as outgoingDateTimeFormatter#defaultFormatand no locale.- Specified by:
mapToin interfaceDateTimeFormatterInterface- Parameters:
src- the datetime formatted string- Returns:
- the date time formatted using the
#defaultFormat.
-
mapFrom
public String mapFrom(String src, DateTimeFormatter incomingFormat)
Description copied from interface:DateTimeFormatterInterfaceUses as incomingDateTimeFormatter#defaultFormat.- Specified by:
mapFromin interfaceDateTimeFormatterInterface- Parameters:
src- the datetime formatted string- Returns:
- the newly formatted date time string
-
map
public String map(String src, DateTimeFormatter outgoingFormat, Locale locale)
- Specified by:
mapin interfaceDateTimeFormatterInterface
-
-