org.jscience.ml.om.util
Class DateConverter

java.lang.Object
  extended by org.jscience.ml.om.util.DateConverter

public class DateConverter
extends java.lang.Object

The DateConverter is a helper class that provides methods for handling the all kind of date formats.
E.g. the ISO8601 date format (A short summary about the ISO8601 date format can be accessed at the W3C.), or the Julian date.

Since:
1.0

Constructor Summary
DateConverter()
           
 
Method Summary
static java.util.Calendar toDate(java.lang.String iso8601)
          Converts a String object that contains a ISO8601 conform value to an java.util.Calendar object.
static java.util.Calendar toGregorianDate(double julianDate)
          Converts a julian date into a gregorian date.
static java.util.Calendar toGregorianDate(double julianDate, java.util.TimeZone zone)
          Converts a julian date into a gregorian date.
static java.lang.String toISO8601(java.util.Calendar calendar)
          Converts a Date object into a String object that represents a ISO8601 conform string.
static double toJulianDate(java.util.Calendar gregorianCalendar)
          Converts a gregorian date into a julian date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateConverter

public DateConverter()
Method Detail

toJulianDate

public static double toJulianDate(java.util.Calendar gregorianCalendar)
Converts a gregorian date into a julian date.

Parameters:
gregorianCalendar - The gregorianDate date
Returns:
A julian date with seconds accuracy
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

toGregorianDate

public static java.util.Calendar toGregorianDate(double julianDate)
Converts a julian date into a gregorian date.

Parameters:
julianDate - The julian date
Returns:
A gregorian date with seconds accuracy (Timezone = GMT)

toGregorianDate

public static java.util.Calendar toGregorianDate(double julianDate,
                                                 java.util.TimeZone zone)
Converts a julian date into a gregorian date.

Parameters:
julianDate - The julian date
zone - The timzone for the returned gregorian date (if NULL is passed GMT will be taken)
Returns:
A gregorian date
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

toISO8601

public static java.lang.String toISO8601(java.util.Calendar calendar)
Converts a Date object into a String object that represents a ISO8601 conform string.

Parameters:
calendar - A java.util.Date object that has to be converted
Returns:
A ISO8601 conform String, or null if the given date was null

toDate

public static java.util.Calendar toDate(java.lang.String iso8601)
                                 throws java.lang.NumberFormatException
Converts a String object that contains a ISO8601 conform value to an java.util.Calendar object.

Parameters:
iso8601 - A String with a ISO8601 conform value
Returns:
The parameters date as java.util.Calendar, or null if the given string was null or empty.
Throws:
java.lang.NumberFormatException - if given ISO8601 is malformed.