net.sourceforge.calendardate
Class CalendarDateFormat

java.lang.Object
  extended bynet.sourceforge.calendardate.CalendarDateFormat

public class CalendarDateFormat
extends java.lang.Object

Formats and parses CalendarDates in a locale-sensitive manner based on a pattern string.
For example for a date representing June 12, 2004:

The pattern and format rules are the same as for java.text.SimpleDateFormat, except that only the following pattern letters are useful:

Letter Date Component Examples
G Era designator AD
y Year 1996;96
M Month in year July;Jul;07
d Day in month 10
E Day in week Tuesday;Tue

See Also:
SimpleDateFormat

Constructor Summary
CalendarDateFormat(java.text.SimpleDateFormat format)
          Creates a format object based on the given simple date format.
CalendarDateFormat(java.lang.String pattern)
          Creates a format object based on the given date pattern.
 
Method Summary
 java.lang.String format(CalendarDate date)
          Creates a text-based representation of the given date
 CalendarDate parse(java.lang.String source)
          Parses the given string to produce a CalendarDate.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalendarDateFormat

public CalendarDateFormat(java.lang.String pattern)
Creates a format object based on the given date pattern. The resulting format is NOT lenient (i.e. "32-Jan-2004" will result in a ParseException, rather than returning 01-Jan-2004)

Parameters:
pattern - the pattern string - see class doc for more information
Throws:
java.lang.IllegalArgumentException - if the given pattern is invalid

CalendarDateFormat

public CalendarDateFormat(java.text.SimpleDateFormat format)
Creates a format object based on the given simple date format.

Method Detail

format

public java.lang.String format(CalendarDate date)
Creates a text-based representation of the given date

Parameters:
date - The date to be formatted
Returns:
The String form of the given date

parse

public CalendarDate parse(java.lang.String source)
                   throws java.text.ParseException
Parses the given string to produce a CalendarDate.

Parameters:
source - The text to parse
Returns:
A CalendarDate matching the given string
Throws:
java.text.ParseException - If one of the following this true:
  1. The String doesn't match the format of this pattern
  2. The date represented by source is outside the valid CalendarDate range