org.springmodules.validation.util.date
Class DefaultDateParser

java.lang.Object
  extended by org.springmodules.validation.util.date.DefaultDateParser
All Implemented Interfaces:
DateParser

public class DefaultDateParser
extends Object
implements DateParser

DefaultDateParser parses many date formats to a string.

The supported date formats are:

Date formats can be added using DefaultDateParser#register(String, String).

These modifiers are supported:

Modifiers can be added using DefaultDateParser#register(String, DateModifier).

Modifiers can be combined and are parsed from left to right, for example:

2005-04-09 23:30:00>M+10d+8H results in 2005-05-11 08:00:00.

Since:
25-04-2005
Author:
Steven Devijver

Nested Class Summary
static interface DefaultDateParser.DateModifier
           
 
Constructor Summary
DefaultDateParser()
           
 
Method Summary
static DefaultDateParser getInstance()
           
 Date parse(String str)
           
 void register(String regexp, DefaultDateParser.DateModifier dateParser)
          Register your own date parser for a given regular expression.
 void register(String regexp, String format)
          Register a date format for a given regular expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDateParser

public DefaultDateParser()
Method Detail

getInstance

public static DefaultDateParser getInstance()

parse

public Date parse(String str)
           throws DateParseException
Specified by:
parse in interface DateParser
Throws:
DateParseException

register

public void register(String regexp,
                     String format)

Register a date format for a given regular expression.

Parameters:
regexp - the regular expression
format - the date format

register

public void register(String regexp,
                     DefaultDateParser.DateModifier dateParser)

Register your own date parser for a given regular expression.

Parameters:
regexp - the regular expression
dateParser - the date parser


Copyright © 2009. All Rights Reserved.