Class DateTimeFormatterTool
- java.lang.Object
-
- org.apache.turbine.services.pull.util.DateTimeFormatterTool
-
- All Implemented Interfaces:
DateTimeFormatterInterface,ApplicationTool
public class DateTimeFormatterTool extends Object implements ApplicationTool, DateTimeFormatterInterface
This pull tool 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.
-
-
Constructor Summary
Constructors Constructor Description DateTimeFormatterTool()
-
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 #DateTimeFormatterTool#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()DateTimeFormatterServicegetDtfs()voidinit(Object data)Initialize the application tool.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.voidrefresh()Refresh the application tool.
-
-
-
Constructor Detail
-
DateTimeFormatterTool
public DateTimeFormatterTool()
-
-
Method Detail
-
init
public void init(Object data)
Initialize the application tool. The data parameter holds a different type depending on how the tool is being instantiated:- For global tools data will be null
- For request tools data will be of type RunData
- For session and persistent tools data will be of type User
#defaultFormatfrom#dateTimeFormatPatternwith default LocaleLocale.getDefault()and Default zone:ZoneId.systemDefault()- Specified by:
initin interfaceApplicationTool- Parameters:
data- initialization data
-
getDtfs
public DateTimeFormatterService getDtfs()
-
refresh
public void refresh()
Refresh the application tool. This is necessary for development work where you probably want the tool to refresh itself if it is using configuration information that is typically cached after initialization- Specified by:
refreshin interfaceApplicationTool
-
getDefaultFormat
public DateTimeFormatter getDefaultFormat()
- Specified by:
getDefaultFormatin interfaceDateTimeFormatterInterface
-
getDateTimeFormatPattern
public String getDateTimeFormatPattern()
- Specified by:
getDateTimeFormatPatternin interfaceDateTimeFormatterInterface
-
format
public <T extends TemporalAccessor> String format(T temporalAccessor)
Formats the given datetime as a String with the #DateTimeFormatterTool#defaultFormat. using the default date format.- Specified by:
formatin interfaceDateTimeFormatterInterface- Parameters:
the-to format- 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
-
-