xmlBlaster 2.1.0 API

org.xmlBlaster.util
Class IsoDateParser

java.lang.Object
  extended by org.xmlBlaster.util.IsoDateParser

public class IsoDateParser
extends java.lang.Object

Date parser for ISO 8601 format http://www.w3.org/TR/1998/NOTE-datetime-19980827

Version:
$Revision: 1.5 $
Author:
Beno�t Mah� (bmahe@w3.org), Yves Lafon (ylafon@w3.org)

Field Summary
static java.text.SimpleDateFormat utcFmt
           
static java.text.SimpleDateFormat utcFmtT
           
 
Constructor Summary
IsoDateParser()
           
 
Method Summary
private static boolean check(java.util.StringTokenizer st, java.lang.String token)
           
static java.util.Calendar getCalendar(java.lang.String isodate)
           
static java.lang.String getCurrentUTCDate()
           
static java.lang.String getCurrentUTCTime()
           
static java.lang.String getCurrentUTCTimestamp()
           
static java.lang.String getCurrentUTCTimestampNanos()
          Returns currently milli precission or an increment counter if called more than once per milli.
static java.lang.String getCurrentUTCTimestampT()
           
static java.lang.String getIsoDate(java.util.Date date)
          Generate a ISO 8601 date
static java.lang.String getIsoDateNoMillis(java.util.Date date)
          Generate a ISO 8601 date
static java.lang.String getUTCTimestamp(java.util.Date date)
           
static java.lang.String getUTCTimestamp(long millis)
           
static java.lang.String getUTCTimestampT(java.util.Date date)
           
static void main(java.lang.String[] args)
           
static java.util.Date parse(java.lang.String isodate)
          Parse the given string in ISO 8601 format and build a Date object.
static void test(java.util.Date date)
           
static void test(java.lang.String isodate)
           
private static java.lang.String twoDigit(int i)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

utcFmt

public static final java.text.SimpleDateFormat utcFmt

utcFmtT

public static final java.text.SimpleDateFormat utcFmtT
Constructor Detail

IsoDateParser

public IsoDateParser()
Method Detail

getCurrentUTCDate

public static java.lang.String getCurrentUTCDate()
Returns:
The ISO 8601 UTC-time string "2006-02-21"

getCurrentUTCTime

public static java.lang.String getCurrentUTCTime()
Returns:
The ISO 8601 UTC-time string "14:05:51.703Z"

getCurrentUTCTimestamp

public static java.lang.String getCurrentUTCTimestamp()
Returns:
The ISO 8601 UTC-time string, precision is currently millis (three fraction digits) "2006-02-21 14:05:51.703Z"

getCurrentUTCTimestampNanos

public static java.lang.String getCurrentUTCTimestampNanos()
Returns currently milli precission or an increment counter if called more than once per milli.

Returns:
e.g. "2007-07-09 10:35:43.946Z" or "2007-07-09 10:36:38.180000005Z"

getUTCTimestamp

public static java.lang.String getUTCTimestamp(java.util.Date date)

getUTCTimestamp

public static java.lang.String getUTCTimestamp(long millis)

getCurrentUTCTimestampT

public static java.lang.String getCurrentUTCTimestampT()
Returns:
The ISO 8601 UTC-time string, precision is currently millis (three fraction digits) "2006-02-21T14:05:51.703Z"

getUTCTimestampT

public static java.lang.String getUTCTimestampT(java.util.Date date)

check

private static boolean check(java.util.StringTokenizer st,
                             java.lang.String token)
                      throws java.lang.IllegalArgumentException
Parameters:
utc - "2001-02-03 04:05:06.7" public static Date getParseUTC(String utc) { synchronized (utcFmt) { try { return utcFmt.parse(utc); } catch (ParseException e) { throw new IllegalArgumentException("getParseUTC("+utc+"): " + e.toString()); } } }
Throws:
java.lang.IllegalArgumentException

getCalendar

public static java.util.Calendar getCalendar(java.lang.String isodate)
                                      throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

parse

public static java.util.Date parse(java.lang.String isodate)
                            throws java.lang.IllegalArgumentException
Parse the given string in ISO 8601 format and build a Date object.

Parameters:
isodate - the date in ISO 8601 format
Returns:
a Date instance
Throws:
java.lang.IllegalArgumentException - if the date is not valid

twoDigit

private static java.lang.String twoDigit(int i)

getIsoDate

public static java.lang.String getIsoDate(java.util.Date date)
Generate a ISO 8601 date

Parameters:
date - a Date instance
Returns:
a string representing the date in the ISO 8601 format

getIsoDateNoMillis

public static java.lang.String getIsoDateNoMillis(java.util.Date date)
Generate a ISO 8601 date

Parameters:
date - a Date instance
Returns:
a string representing the date in the ISO 8601 format

test

public static void test(java.lang.String isodate)

test

public static void test(java.util.Date date)

main

public static void main(java.lang.String[] args)

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.