|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.conversions.NullConversion<String,T>
com.univocity.parsers.conversions.ObjectConversion<Calendar>
com.univocity.parsers.conversions.CalendarConversion
public class CalendarConversion
Converts Strings to instances of Calendar and vice versa.
This class supports multiple date formats. For example, you can define conversions from dates represented by different Strings such as "2001/05/02 and Dec/2013".
The reverse conversion from a Calendar to String (in revert(Calendar) will return a formatted String using the date pattern provided in this class constructor
The date patterns must follows the pattern rules of SimpleDateFormat
SimpleDateFormat| Constructor Summary | |
|---|---|
CalendarConversion(Calendar valueIfStringIsNull,
String valueIfObjectIsNull,
String... dateFormats)
Defines a conversion from String to Calendar using a sequence of acceptable date patterns. |
|
CalendarConversion(Locale locale,
Calendar valueIfStringIsNull,
String valueIfObjectIsNull,
String... dateFormats)
Defines a conversion from String to Calendar using a sequence of acceptable date patterns. |
|
CalendarConversion(Locale locale,
String... dateFormats)
Defines a conversion from String to Calendar using a sequence of acceptable date patterns. |
|
CalendarConversion(String... dateFormats)
Defines a conversion from String to Calendar using a sequence of acceptable date patterns. |
|
| Method Summary | |
|---|---|
protected Calendar |
fromString(String input)
Converts a formatted date String to an instance of Calendar. |
SimpleDateFormat[] |
getFormatterObjects()
Returns the formatter objects |
String |
revert(Calendar input)
Converts Calendar to a formatted date String. |
| Methods inherited from class com.univocity.parsers.conversions.ObjectConversion |
|---|
execute, fromInput, getValueIfObjectIsNull, getValueIfStringIsNull, setValueIfObjectIsNull, setValueIfStringIsNull, undo |
| Methods inherited from class com.univocity.parsers.conversions.NullConversion |
|---|
getValueOnNullInput, getValueOnNullOutput, setValueOnNullInput, setValueOnNullOutput |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CalendarConversion(Locale locale,
Calendar valueIfStringIsNull,
String valueIfObjectIsNull,
String... dateFormats)
Calendar using a sequence of acceptable date patterns.
This constructor assumes the output of a conversion should be null when input is null
locale - the Locale that determines how the date mask should be formatted.valueIfStringIsNull - default Calendar value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.valueIfObjectIsNull - default String value to be returned when a Calendar input is null. Used when revert(Calendar) is invoked.dateFormats - list of acceptable date patterns The first pattern in this sequence will be used to convert a Calendar into a String in revert(Calendar).
public CalendarConversion(Calendar valueIfStringIsNull,
String valueIfObjectIsNull,
String... dateFormats)
Calendar using a sequence of acceptable date patterns.
This constructor assumes the output of a conversion should be null when input is null
valueIfStringIsNull - default Calendar value to be returned when the input String is null. Used when ObjectConversion.execute(String) is invoked.valueIfObjectIsNull - default String value to be returned when a Calendar input is null. Used when revert(Calendar) is invoked.dateFormats - list of acceptable date patterns The first pattern in this sequence will be used to convert a Calendar into a String in revert(Calendar).
public CalendarConversion(Locale locale,
String... dateFormats)
Calendar using a sequence of acceptable date patterns.
This constructor assumes the output of a conversion should be null when input is null
locale - the Locale that determines how the date mask should be formatted.dateFormats - list of acceptable date patterns The first pattern in this sequence will be used to convert a Calendar into a String in revert(Calendar).public CalendarConversion(String... dateFormats)
Calendar using a sequence of acceptable date patterns.
This constructor assumes the output of a conversion should be null when input is null
dateFormats - list of acceptable date patterns The first pattern in this sequence will be used to convert a Calendar into a String in revert(Calendar).| Method Detail |
|---|
public String revert(Calendar input)
The pattern used to generate the formatted date is the first date pattern provided in the constructor of this class
revert in interface Conversion<String,Calendar>revert in class ObjectConversion<Calendar>input - the Calendar to be converted to a String
ObjectConversion.getValueIfObjectIsNull() if the Calendar parameter is null.protected Calendar fromString(String input)
The pattern in the formatted date must match one of the date patterns provided in the constructor of this class.
fromString in class ObjectConversion<Calendar>input - the String containing a formatted date which must be converted to a Calendar
ObjectConversion.getValueIfStringIsNull() if the String input is null.public SimpleDateFormat[] getFormatterObjects()
FormattedConversion
getFormatterObjects in interface FormattedConversion<SimpleDateFormat>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||