bb.util
Class DateUtil.IsoDateFormat

java.lang.Object
  extended by java.text.Format
      extended by java.text.DateFormat
          extended by java.text.SimpleDateFormat
              extended by bb.util.DateUtil.IsoDateFormat
All Implemented Interfaces:
Serializable, Cloneable
Enclosing class:
DateUtil

private static class DateUtil.IsoDateFormat
extends SimpleDateFormat

Formats/parses dates that are ISO 8601 compliant.

An ISO 8601 year date must start with a -/+ char to denote the BC/AD era. Next comes at least 4 digits (zero padded if necessary) that specify the year. For the special case of an AD era year that has exactly 4 digits, the ISO 8601 spec allows the + era prefix to be dropped, as it may then be implicitly understood; this class follows that option, to conform with how people usually write dates. It will correctly parse any ISO 8601 compliant String, even ones that do not follow the above option (i.e. always start with a - or + era char).


Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.DateFormat
DateFormat.Field
 
Field Summary
private static long serialVersionUID
           
 
Fields inherited from class java.text.DateFormat
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD
 
Constructor Summary
private DateUtil.IsoDateFormat(String pattern)
           
 
Method Summary
 StringBuffer format(Date date, StringBuffer sb, FieldPosition pos)
           
 Date parse(String s)
           
 
Methods inherited from class java.text.SimpleDateFormat
applyLocalizedPattern, applyPattern, clone, equals, formatToCharacterIterator, get2DigitYearStart, getDateFormatSymbols, hashCode, parse, set2DigitYearStart, setDateFormatSymbols, toLocalizedPattern, toPattern
 
Methods inherited from class java.text.DateFormat
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone
 
Methods inherited from class java.text.Format
format, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

DateUtil.IsoDateFormat

private DateUtil.IsoDateFormat(String pattern)
                        throws IllegalArgumentException
Throws:
IllegalArgumentException
Method Detail

format

public StringBuffer format(Date date,
                           StringBuffer sb,
                           FieldPosition pos)
Overrides:
format in class SimpleDateFormat

parse

public Date parse(String s)
           throws ParseException
Overrides:
parse in class DateFormat
Throws:
ParseException