org.weborganic.ox.util
Enum ISO8601

java.lang.Object
  extended by java.lang.Enum<ISO8601>
      extended by org.weborganic.ox.util.ISO8601
All Implemented Interfaces:
Serializable, Comparable<ISO8601>

public enum ISO8601
extends Enum<ISO8601>

This class provides methods for date formatting and parsing according to ISO 8601.

It is useful for generators as XSLT uses ISO 8601 for dates.

Notation:

The capital letter T is used to separate the date and time components.

Since:
Berlioz 0.6
Version:
Berlioz 0.9.4 - 31 January 2012
Author:
Christophe Lauret
See Also:
Wikipedia: ISO 8601, W3C Note: Date and Time Formats, ISO: Numeric representation of Dates and Time

Enum Constant Summary
CALENDAR_DATE
          The calendar date as defined by ISO 8601, 'YYYY-MM-DD' (Example: 2003-04-01).
DATETIME
          The Date and time as defined by ISO 8601, 'YYYY-MM-DDThh:mm:ss'.
TIME
          The time of the day as defined by ISO 8601, 'hh:mm:ss' (Example: 23:59:59).
WEEK_DATE
          The week date as defined by ISO 8601, 'YYYY-MM-DD' (Example: 2003-W14-2).
YEAR
          The calendar date as defined by ISO 8601, 'YYYY' (Example: 2010).
 
Method Summary
 String format(long date)
          Formats the specified date for the specified ISO 8601 format.
static String format(long date, ISO8601 format)
          Returns the specified date as ISO 8601 format.
 Date parse(String date)
          Parses the specified date as the specified ISO 8601 format.
static Date parseAuto(String date)
          Returns the specified date as ISO 8601 format.
static ISO8601 valueOf(String name)
          Returns the enum constant of this type with the specified name.
static ISO8601[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

YEAR

public static final ISO8601 YEAR
The calendar date as defined by ISO 8601, 'YYYY' (Example: 2010).


CALENDAR_DATE

public static final ISO8601 CALENDAR_DATE
The calendar date as defined by ISO 8601, 'YYYY-MM-DD' (Example: 2003-04-01).


WEEK_DATE

public static final ISO8601 WEEK_DATE
The week date as defined by ISO 8601, 'YYYY-MM-DD' (Example: 2003-W14-2).


TIME

public static final ISO8601 TIME
The time of the day as defined by ISO 8601, 'hh:mm:ss' (Example: 23:59:59).


DATETIME

public static final ISO8601 DATETIME
The Date and time as defined by ISO 8601, 'YYYY-MM-DDThh:mm:ss'.

Method Detail

values

public static ISO8601[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (ISO8601 c : ISO8601.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static ISO8601 valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

format

public String format(long date)
Formats the specified date for the specified ISO 8601 format.

Parameters:
date - The date the format
Returns:
the corresponding date as the specified ISO 8601 format.

parse

public Date parse(String date)
           throws ParseException
Parses the specified date as the specified ISO 8601 format.

Parameters:
date - The date the format
Returns:
the corresponding date as the specified ISO 8601 format.
Throws:
ParseException - Should an error be thrown by the DateFormat.parse(String) method.

format

public static String format(long date,
                            ISO8601 format)
Returns the specified date as ISO 8601 format.

Parameters:
date - the specified date.
format - the ISO 8601 format to use.
Returns:
the date formatted using ISO 8601.

parseAuto

public static Date parseAuto(String date)
                      throws ParseException
Returns the specified date as ISO 8601 format.

Parameters:
date - the specified date.
Returns:
the date formatted using ISO 8601.
Throws:
ParseException - Should an error be thrown by the DateFormat.parse(String) method.