Class FormattedDateConversion
- java.lang.Object
-
- com.univocity.parsers.conversions.FormattedDateConversion
-
- All Implemented Interfaces:
Conversion<java.lang.Object,java.lang.String>
public class FormattedDateConversion extends java.lang.Object implements Conversion<java.lang.Object,java.lang.String>
Converts objects of different date types (java.util.Date
andjava.util.Calendar
) to a formatted dateString
.The reverse conversion is not supported.
The date patterns must follow the pattern rules of
SimpleDateFormat
- See Also:
SimpleDateFormat
-
-
Field Summary
Fields Modifier and Type Field Description private java.text.SimpleDateFormat
dateFormat
private java.lang.String
valueIfObjectIsNull
-
Constructor Summary
Constructors Constructor Description FormattedDateConversion(java.lang.String format, java.util.Locale locale, java.lang.String valueIfObjectIsNull)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
execute(java.lang.Object input)
Converts a value of type I to a value of type O.java.lang.Object
revert(java.lang.String input)
Unsupported operation.
-
-
-
Constructor Detail
-
FormattedDateConversion
public FormattedDateConversion(java.lang.String format, java.util.Locale locale, java.lang.String valueIfObjectIsNull)
- Parameters:
format
- The pattern to be used to convert an input date into a String inexecute(Object)
.locale
- theLocale
that determines how the date mask should be formatted.valueIfObjectIsNull
- default String value to be returned when an input isnull
. Used whenexecute(Object)
is invoked with anull
parameter.
-
-
Method Detail
-
execute
public java.lang.String execute(java.lang.Object input)
Description copied from interface:Conversion
Converts a value of type I to a value of type O. When used in conjunction with theConvert
annotation, this method will perform the conversion from a parsed inputString
(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- Specified by:
execute
in interfaceConversion<java.lang.Object,java.lang.String>
- Parameters:
input
- the input of type I to be converted to an object of type O- Returns:
- the conversion result.
-
revert
public java.lang.Object revert(java.lang.String input)
Unsupported operation.- Specified by:
revert
in interfaceConversion<java.lang.Object,java.lang.String>
- Parameters:
input
- the input be converted.- Returns:
- throws a
UnsupportedOperationException
-
-