public class DateStringParser extends PropertyStringParser
StringParser
for parsing java.util.Date objects. By default, arguments
are parsed using the
java.text.SimpleDateFormat for the default locale. The format can be
overridden using this StringParser's
setProperties() method, supplying a java.util.Properties object with a
property key named "format".
The value associated with the "format" property is used to create a new
java.text.SimpleDateFormat
to parse the argument.
A ParseException is thrown if a SimpleDateFormat cannot be constructed with the specified format, or if the SimpleDateFormat throws a java.text.ParseException during parsing.
The SimpleDateFormat object is instantiated when an option referencing this DateStringParser is registered with a JSAP object.
StringParser
,
Date
,
SimpleDateFormat
Constructor and Description |
---|
DateStringParser()
Deprecated.
Use
getParser() . |
Modifier and Type | Method and Description |
---|---|
static DateStringParser |
getParser()
Returns a
DateStringParser . |
Object |
parse(String arg)
Parses the specified argument using either the java.text.SimpleDateFormat
for the current locale
(by default) or a java.text.SimpleDateFormat as defined by this
PropertyStringParser's "format"
property.
|
void |
setUp()
Instantiates the SimpleDateFormat to use for parsing.
|
void |
tearDown()
Destroys the SimpleDateFormat used for parsing.
|
getProperty, getProperty, setProperty
public DateStringParser()
getParser()
.public static DateStringParser getParser()
DateStringParser
.DateStringParser
.public void setUp() throws ParseException
setUp
in class StringParser
ParseException
- if a SimpleDateFormat cannot be instantiated with
the contents of the
"format" property.public void tearDown()
tearDown
in class StringParser
public Object parse(String arg) throws ParseException
parse
in class StringParser
arg
- the argument to convert to a Date.ParseException
- if the specified argument cannot be parsed by the
current format..Copyright © 2015. All rights reserved.