- java.lang.Object
-
- com.pervasive.datarush.encoding.text.DateFormatter
-
- All Implemented Interfaces:
TokenFormatter
public class DateFormatter extends Object
A formatter representing date token values with a user-defined text format.Parsing is done using the Joda time library which uses a similar format to that described in
SimpleDateFormat. Most specifiers compatible with the JDK will be compatible with Joda time, the notable exceptions being:- The 'W' (week in month) specifier is not supported.
- The 'F' (day of week as number) specifier is replaced with 'e'.
-
-
Constructor Summary
Constructors Constructor Description DateFormatter(DateTimeFormatting format, String nullIndicator)Creates a formatter using the specified format.DateFormatter(String pattern)Creates a formatter using the specified format.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringformat()Formats the current value of the source as a text value.voidsetSource(ScalarValued source)Sets the container holding values to be formatted.
-
-
-
Constructor Detail
-
DateFormatter
public DateFormatter(String pattern)
Creates a formatter using the specified format. Null values are output as the empty string.- Parameters:
pattern- the output format to use
-
DateFormatter
public DateFormatter(DateTimeFormatting format, String nullIndicator)
Creates a formatter using the specified format. Null values are output as the specified string.- Parameters:
format- the output format to usenullIndicator- the text value to use for null values
-
-
Method Detail
-
setSource
public final void setSource(ScalarValued source)
Description copied from interface:TokenFormatterSets the container holding values to be formatted. A reference to this container is held and accessed only when an formatting is requested.- Specified by:
setSourcein interfaceTokenFormatter- Parameters:
source- the value container to format
-
format
public final String format()
Description copied from interface:TokenFormatterFormats the current value of the source as a text value.- Specified by:
formatin interfaceTokenFormatter- Returns:
- the value of the source as a string
-
-