public class DateParser extends java.lang.Object implements DataParser
DateFormat
instance to
perform parsing. The DateFormat instance to use can be passed in to the
constructor, or by default the DateFormat returned by
DateFormat.getDateInstance(int)
with an
argument of DateFormat.SHORT
is used.Modifier and Type | Field and Description |
---|---|
protected java.text.DateFormat |
m_dfmt |
protected java.text.ParsePosition |
m_pos |
Constructor and Description |
---|
DateParser()
Create a new DateParser.
|
DateParser(java.text.DateFormat dateFormat)
Create a new DateParser.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canParse(java.lang.String text)
Indicates if the given text string can be successfully parsed by
this parser.
|
java.lang.String |
format(java.lang.Object value)
Get a String representation for the given value.
|
java.lang.Class |
getType()
Returns java.sql.Date.
|
java.lang.Object |
parse(java.lang.String text)
Parse the given text string to a data value.
|
java.sql.Date |
parseDate(java.lang.String text)
Parse a Date value from a text string.
|
protected java.text.DateFormat m_dfmt
protected java.text.ParsePosition m_pos
public DateParser()
public DateParser(java.text.DateFormat dateFormat)
dateFormat
- the DateFormat instance to use for parsingpublic java.lang.Class getType()
getType
in interface DataParser
DataParser.getType()
public java.lang.String format(java.lang.Object value)
DataParser
format
in interface DataParser
value
- the object value to formatDataParser.format(java.lang.Object)
public boolean canParse(java.lang.String text)
DataParser
canParse
in interface DataParser
text
- the text string to check for parsabilityDataParser.canParse(java.lang.String)
public java.lang.Object parse(java.lang.String text) throws DataParseException
DataParser
parse
in interface DataParser
text
- the text string to parseDataParser.getType()
methodDataParseException
- if an error occurs during parsingDataParser.parse(java.lang.String)
public java.sql.Date parseDate(java.lang.String text) throws DataParseException
text
- the text string to parseDataParseException
- if an error occurs during parsingCopyright ? 2013 Regents of the University of California