eXo Kernel :: Commons Utils 2.4.10-UXP01

org.exoplatform.commons.utils
Class ISO8601

java.lang.Object
  extended by org.exoplatform.commons.utils.ISO8601

public class ISO8601
extends Object

Created by The eXo Platform SAS Author : Peter Nedonosko peter.nedonosko@exoplatform.com.ua 05.07.2007 ISO 8601 standard Year: YYYY (eg 1997) Year and month: YYYY-MM (eg 1997-07) Complete date: YYYY-MM-DD (eg 1997-07-16) Complete date plus hours and minutes: YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00) Complete date plus hours, minutes and seconds: YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00) Complete date plus hours, minutes, seconds and a decimal fraction of a second YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) where: YYYY = four-digit year MM = two-digit month (01=January, etc.) DD = two-digit day of month (01 through 31) hh = two digits of hour (00 through 23) (am/pm NOT allowed) mm = two digits of minute (00 through 59) ss = two digits of second (00 through 59) s = one or more digits representing a decimal fraction of a second TZD = time zone designator (Z or +hh:mm or -hh:mm) a RFC 822 time zone is also accepted: For formatting, the RFC 822 4-digit time zone format is used: RFC822TimeZone: Sign TwoDigitHours Minutes TwoDigitHours: Digit Digit like -8000

Version:
$Id: ISO8601.java 34394 2009-07-23 09:23:31Z dkatayev $
Author:
Peter Nedonosko

Nested Class Summary
protected static class ISO8601.ISODateFormat
           
 
Field Summary
static String COMPLETE_DATE_FORMAT
          Complete date: YYYY-MM-DD (eg 1997-07-16)
static String COMPLETE_DATEHOURSMINUTESZ_FORMAT
          Complete date plus hours and minutes: YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
static String COMPLETE_DATEHOURSMINUTESZRFC822_FORMAT
          NON ISO STANDARD.
static String COMPLETE_DATETIMEMSZ_FORMAT
          Complete date plus hours, minutes, seconds and a decimal fraction of a second YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
static String COMPLETE_DATETIMEMSZRFC822_FORMAT
          Complete date plus hours, minutes, seconds and a decimal fraction of a second, with timezone by RFC822 YYYY-MM-DDThh:mm:ss.sZ (eg 1997-07-16T19:20:30.45+0100)
static String COMPLETE_DATETIMEZ_FORMAT
          Complete date plus hours, minutes and seconds: YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
static String COMPLETE_DATETIMEZRFC822_FORMAT
          NON ISO STANDARD.
static String[] FORMATS
          Possible formats list.
static String SIMPLE_DATEHOURSMINUTES_FORMAT
          NON ISO STANDARD.
static String SIMPLE_DATETIME_FORMAT
          NON ISO STANDARD.
static String SIMPLE_DATETIMEMS_FORMAT
          NON ISO STANDARD.
protected static String TZD
          ISO 8601 time zone designator
static String YEAR_FORMAT
          Year: YYYY (eg 1997)
static String YEARMONTH_FORMAT
          Year and month: YYYY-MM (eg 1997-07)
 
Constructor Summary
ISO8601()
           
 
Method Summary
static String format(Calendar date)
          Format date using format: complete date plus hours, minutes, seconds and a decimal fraction of a second.
static Calendar parse(String dateString)
          Parse string using possible formats list.
static Calendar parse(String dateString, String[] formats)
          Parse string using given formats list.
static Calendar parseEx(String dateString)
          Parse string using possible formats list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TZD

protected static final String TZD
ISO 8601 time zone designator

See Also:
Constant Field Values

YEAR_FORMAT

public static final String YEAR_FORMAT
Year: YYYY (eg 1997)

See Also:
Constant Field Values

YEARMONTH_FORMAT

public static final String YEARMONTH_FORMAT
Year and month: YYYY-MM (eg 1997-07)

See Also:
Constant Field Values

COMPLETE_DATE_FORMAT

public static final String COMPLETE_DATE_FORMAT
Complete date: YYYY-MM-DD (eg 1997-07-16)

See Also:
Constant Field Values

SIMPLE_DATEHOURSMINUTES_FORMAT

public static final String SIMPLE_DATEHOURSMINUTES_FORMAT
NON ISO STANDARD. Simple date plus hours and minutes, wothout timezone: YYYY-MM-DDThh:mm (eg 1997-07-16T19:20)

See Also:
Constant Field Values

COMPLETE_DATEHOURSMINUTESZRFC822_FORMAT

public static final String COMPLETE_DATEHOURSMINUTESZRFC822_FORMAT
NON ISO STANDARD. Complete date plus hours and minutes, with timezone by RFC822: YYYY-MM-DDThh:mmZ (eg 1997-07-16T19:20+0100)

See Also:
Constant Field Values

COMPLETE_DATEHOURSMINUTESZ_FORMAT

public static final String COMPLETE_DATEHOURSMINUTESZ_FORMAT
Complete date plus hours and minutes: YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)

See Also:
Constant Field Values

SIMPLE_DATETIME_FORMAT

public static final String SIMPLE_DATETIME_FORMAT
NON ISO STANDARD. Simple date plus hours, minutes and seconds, wothout timezone: YYYY-MM-DDThh:mm:ss (eg 1997-07-16T19:20:30)

See Also:
Constant Field Values

COMPLETE_DATETIMEZRFC822_FORMAT

public static final String COMPLETE_DATETIMEZRFC822_FORMAT
NON ISO STANDARD. Complete date plus hours, minutes and seconds, with timezone by RFC822: YYYY-MM-DDThh:mm:ssZ (eg 1997-07-16T19:20:30+0100)

See Also:
Constant Field Values

COMPLETE_DATETIMEZ_FORMAT

public static final String COMPLETE_DATETIMEZ_FORMAT
Complete date plus hours, minutes and seconds: YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)

See Also:
Constant Field Values

SIMPLE_DATETIMEMS_FORMAT

public static final String SIMPLE_DATETIMEMS_FORMAT
NON ISO STANDARD. Simple date plus hours, minutes, seconds and a decimal fraction of a second, wothout timezone YYYY-MM-DDThh:mm:ss.s (eg 1997-07-16T19:20:30.45)

See Also:
Constant Field Values

COMPLETE_DATETIMEMSZRFC822_FORMAT

public static final String COMPLETE_DATETIMEMSZRFC822_FORMAT
Complete date plus hours, minutes, seconds and a decimal fraction of a second, with timezone by RFC822 YYYY-MM-DDThh:mm:ss.sZ (eg 1997-07-16T19:20:30.45+0100)

See Also:
Constant Field Values

COMPLETE_DATETIMEMSZ_FORMAT

public static final String COMPLETE_DATETIMEMSZ_FORMAT
Complete date plus hours, minutes, seconds and a decimal fraction of a second YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)

See Also:
Constant Field Values

FORMATS

public static final String[] FORMATS
Possible formats list. ISO 8601, RFC822 + simple formats in order of priority of parse

Constructor Detail

ISO8601

public ISO8601()
Method Detail

format

public static String format(Calendar date)
Format date using format: complete date plus hours, minutes, seconds and a decimal fraction of a second.

Parameters:
date -
Returns:

parse

public static Calendar parse(String dateString)
Parse string using possible formats list.

Parameters:
dateString - - date string
Returns:
- calendar or null if dateString is inparseable text

parseEx

public static Calendar parseEx(String dateString)
                        throws ParseException,
                               NumberFormatException
Parse string using possible formats list.

Parameters:
dateString - - date string
Returns:
- calendar
Throws:
ParseException, - NumberFormatException
ParseException
NumberFormatException

parse

public static Calendar parse(String dateString,
                             String[] formats)
                      throws ParseException
Parse string using given formats list.

Parameters:
dateString -
formats -
Returns:
Throws:
ParseException
NumberFormatException

eXo Kernel :: Commons Utils 2.4.10-UXP01

Copyright © 2014 eXo Platform SAS. All Rights Reserved.