DateStringParser (JSAP: the Java Simple Argument Parser)
Keywords: com.martiansoftware.jsap.stringparsers.DateStringParser class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.martiansoftware.jsap.stringparsers
Class DateStringParser

    java.lang.Object
      com.martiansoftware.jsap.StringParser
          com.martiansoftware.jsap.PropertyStringParser
              com.martiansoftware.jsap.stringparsers.DateStringParser

    public class DateStringParser

extends PropertyStringParser

A `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.

Author:
  Marty Lamb
See Also:
  `StringParser`, `Date`, `SimpleDateFormat`

Constructor Summary
`DateStringParser()` Deprecated. Use `getParser()`.

Method Summary
`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.

Methods inherited from class com.martiansoftware.jsap.PropertyStringParser
`getProperty, getProperty, setProperty`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DateStringParser

    public DateStringParser()

  Deprecated. Use `getParser()`.

  Creates a new DateStringParser.

Method Detail

### getParser

    public static DateStringParser getParser()

  Returns a `DateStringParser`.

  Returns:
    a `DateStringParser`.

### setUp

    public void setUp()
               throws ParseException

  Instantiates the SimpleDateFormat to use for parsing.

  Overrides:
    `setUp` in class `StringParser`
  Throws:
    `ParseException` - if a SimpleDateFormat cannot be instantiated with the contents of the "format" property.

### tearDown

    public void tearDown()

  Destroys the SimpleDateFormat used for parsing.

  Overrides:
    `tearDown` in class `StringParser`

### parse

    public Object parse(String arg)
                 throws ParseException

  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. If the specified argument cannot be parsed by the current format, a ParseException is thrown.

  Specified by:
    `parse` in class `StringParser`
  Parameters:
    `arg` - the argument to convert to a Date.
  Returns:
    a Date as described above.
  Throws:
    `ParseException` - if the specified argument cannot be parsed by the current format..

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2005, Martian Software, Inc.. All Rights Reserved.
For the latest version and documentation, please visit http://www.martiansoftware.com/jsap