Top Description Fields Constructors Methods
com.univocity.parsers.conversions

public Class FormattedDateConversion

extends Object
implements Conversion<Object, String>
Class Inheritance
All Implemented Interfaces
com.univocity.parsers.conversions.Conversion
Imports
com.univocity.parsers.common.*, java.text.*, java.util.*

Converts objects of different date types (java.util.Date and java.util.Calendar) to a formatted date String.

The reverse conversion is not supported.

The date patterns must follow the pattern rules of SimpleDateFormat

Author
Univocity Software Pty Ltd - [email protected]
See Also
SimpleDateFormat

Field Summary

Modifier and TypeField and Description
private final SimpleDateFormat
private final String

Constructor Summary

AccessConstructor and Description
public
FormattedDateConversion(String
The pattern to be used to convert an input date into a String in FormattedDateConversion#execute(Object).
format
,
Locale
the Locale that determines how the date mask should be formatted.
locale
,
String
default String value to be returned when an input is null . Used when FormattedDateConversion#execute(Object) is invoked with a null parameter.
valueIfObjectIsNull
)

Method Summary

Modifier and TypeMethod and Description
public String
execute(Object
the input of type I to be converted to an object of type O
input
)

Implements com.univocity.parsers.conversions.Conversion.execute.

Converts a value of type I to a value of type O.
public Object

Returns:

throws a UnsupportedOperationException
revert
(String
the input be converted.
input
)

Implements com.univocity.parsers.conversions.Conversion.revert.

Unsupported operation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dateFormatback to summary
private final SimpleDateFormat dateFormat
valueIfObjectIsNullback to summary
private final String valueIfObjectIsNull

Constructor Detail

FormattedDateConversionback to summary
public FormattedDateConversion(String format, Locale locale, String valueIfObjectIsNull)
Parameters
format:String

The pattern to be used to convert an input date into a String in FormattedDateConversion#execute(Object).

locale:Locale

the Locale that determines how the date mask should be formatted.

valueIfObjectIsNull:String

default String value to be returned when an input is null . Used when FormattedDateConversion#execute(Object) is invoked with a null parameter.

Method Detail

executeback to summary
public String execute(Object input)

Implements com.univocity.parsers.conversions.Conversion.execute.

Doc from com.univocity.parsers.conversions.Conversion.execute.

Converts a value of type I to a value of type O. When used in conjunction with the com.univocity.parsers.annotations.Convert annotation, this method will perform the conversion from a parsed input String (if no other conversion has been applied before) to a value of the desired type, and the result will be assigned to the annotated field. Note that conversions can be chained so you need to make sure the input type of any previous conversion is compatible with I

Parameters
input:Object

the input of type I to be converted to an object of type O

Returns:String

the conversion result.

Annotations
@Override
revertback to summary
public Object revert(String input)

Implements com.univocity.parsers.conversions.Conversion.revert.

Unsupported operation.

Parameters
input:String

the input be converted.

Returns:Object

throws a UnsupportedOperationException

Annotations
@Override