public class ParseDate extends CellProcessorAdaptor implements StringCellProcessor
SimpleDateFormat
class. If you want to convert from a Date to a String,
use the FmtDate
processor.
Some example date formats you can use are:
"dd/MM/yyyy"
(parses a date formatted as "25/12/2011")
"dd-MMM-yy"
(parses a date formatted as "25-Dec-11")
"yyyy.MM.dd.HH.mm.ss"
(parses a date formatted as "2011.12.25.08.36.33"
"E, dd MMM yyyy HH:mm:ss Z"
(parses a date formatted as "Tue, 25 Dec 2011 08:36:33 -0500")
This processor caters for lenient or non-lenient date interpretations (the default is false for constructors without
a 'lenient' parameter). See DateFormat.setLenient(boolean)
for more information.
If you don't wish to use the default Locale when parsing Dates (your data is formatted for a different Locale), then use the constructor that accepts a Locale.
next
Constructor and Description |
---|
ParseDate(String dateFormat)
Constructs a new ParseDate processor which converts a String to a Date using the supplied date format.
|
ParseDate(String dateFormat,
boolean lenient)
Constructs a new ParseDate processor which converts a String to a Date using the supplied date format.
|
ParseDate(String dateFormat,
boolean lenient,
DateCellProcessor next)
Constructs a new ParseDate processor which converts a String to a Date using the supplied date format,
then calls the next processor in the chain.
|
ParseDate(String dateFormat,
boolean lenient,
Locale locale)
Constructs a new ParseDate processor which converts a String to a Date using the supplied date format
and Locale.
|
ParseDate(String dateFormat,
boolean lenient,
Locale locale,
DateCellProcessor next)
Constructs a new ParseDate processor which converts a String to a Date using the supplied date format
and Locale, then calls the next processor in the chain.
|
ParseDate(String dateFormat,
DateCellProcessor next)
Constructs a new ParseDate processor which converts a String to a Date using the supplied date format,
then calls the next processor in the chain.
|
Modifier and Type | Method and Description |
---|---|
Object |
execute(Object value,
CsvContext context)
This method is invoked by the framework when the processor needs to process data or check constraints.
|
toString, validateInputNotNull
public ParseDate(String dateFormat)
dateFormat
- the date format to useNullPointerException
- if dateFormat is nullpublic ParseDate(String dateFormat, boolean lenient)
dateFormat
- the date format to uselenient
- whether date interpretation is lenientNullPointerException
- if dateFormat is nullpublic ParseDate(String dateFormat, boolean lenient, Locale locale)
dateFormat
- the date format to uselenient
- whether date interpretation is lenientlocale
- the Locale used to parse the dateNullPointerException
- if dateFormat or locale is nullpublic ParseDate(String dateFormat, DateCellProcessor next)
dateFormat
- the date format to usenext
- the next processor in the chainNullPointerException
- if dateFormat or next is nullpublic ParseDate(String dateFormat, boolean lenient, DateCellProcessor next)
dateFormat
- the date format to uselenient
- whether date interpretation is lenientnext
- the next processor in the chainNullPointerException
- if dateFormat or next is nullpublic ParseDate(String dateFormat, boolean lenient, Locale locale, DateCellProcessor next)
dateFormat
- the date format to uselenient
- whether date interpretation is lenientlocale
- the Locale used to parse the datenext
- the next processor in the chainNullPointerException
- if dateFormat, locale, or next is nullpublic Object execute(Object value, CsvContext context)
execute
in interface CellProcessor
value
- the value to be processedcontext
- the CSV contextSuperCsvCellProcessorException
- if value is null, isn't a String, or can't be parsed to a DateCopyright © 2007–2015 Super CSV. All rights reserved.