## visad
Class DateTime

    java.lang.Object
      visad.ThingImpl
          visad.DataImpl
              visad.Scalar
                  visad.Real
                      visad.DateTime

All Implemented Interfaces:
  Cloneable, Comparable, Data, RealIface, ScalarIface, Serializable, Thing

public final class DateTime
extends Real

DateTime is a class of objects for holding date and time information. DateTime objects are immutable.

Internally, the object uses seconds since the epoch (1970-01-01 00:00:00Z) as the temporal reference.

See Also:
  `System.currentTimeMillis()`, Serialized Form

Nested Class Summary

Nested classes inherited from class visad.DataImpl
`DataImpl.Syncher`

Nested classes inherited from class visad.ThingImpl
`ThingImpl.RemotePair`

Field Summary
`static String` `DEFAULT_TIME_FORMAT` Default Time Format Pattern (yyyy-MM-dd HH:mm:ss)
`static TimeZone` `DEFAULT_TIMEZONE` Default Time Zone (GMT)

Fields inherited from class visad.DataImpl
`Type`

Fields inherited from interface visad.Data

`ABS, ACOS, ACOS_DEGREES, ADD, ASIN, ASIN_DEGREES, ATAN, ATAN_DEGREES, ATAN2, ATAN2_DEGREES, CEIL, COS, COS_DEGREES, DEGREES_TO_RADIANS, DEPENDENT, DIVIDE, EXP, FLOOR, INDEPENDENT, INV_ATAN2, INV_ATAN2_DEGREES, INV_DIVIDE, INV_POW, INV_REMAINDER, INV_SUBTRACT, LOG, MAX, MIN, MULTIPLY, NEAREST_NEIGHBOR, NEGATE, NO_ERRORS, NOP, POW, RADIANS_TO_DEGREES, REMAINDER, RINT, ROUND, SIN, SIN_DEGREES, SQRT, SUBTRACT, TAN, TAN_DEGREES, WEIGHTED_AVERAGE`

Constructor Summary
`DateTime()` Construct a DateTime object and initialize it to the current date/time.
`DateTime(Date date)` Construct a DateTime object and initialize it with a Java date.
`DateTime(double seconds)` Construct a DateTime object and initialize it with the seconds since January 1, 1970 00:00:00Z.
`DateTime(double timeValue, Unit timeUnits)` Construct a DateTime object from a tim value and a Unit
`DateTime(int year, int day, double seconds)` Construct a DateTime object initialized with a year, day of the year, and seconds in the day.
`DateTime(Real real)` Construct a DateTime object and initialize it using a VisAD Real.

Method Summary
`int` `compareTo(Object oo)` Implement Comparable interface
`static DateTime` `createDateTime(String dateString)` Create a DateTime object from a string specification
`static DateTime` `createDateTime(String dateString, String format)` Create a DateTime object from a string specification using the supplied pattern and default timezone.
`static DateTime` `createDateTime(String dateString, String format, TimeZone timezone)` Create a DateTime object from a string specification using the supplied pattern and timezone.
`String` `dateString()` Return a string representing the "date" portion of this DateTime
`String` `formattedString(String pattern, TimeZone timezone)` Return a string representation of this DateTime from a user specified format.
`static Real` `fromYearDaySeconds(int year, int day, double seconds)` Return a Real object whose value is the seconds since the Epoch initialized with a year, day of the year, and seconds in the day.
`static String` `getFormatPattern()` Return the format pattern used in the output of the toString() method.
`static TimeZone` `getFormatTimeZone()` Return the TimeZone used in the output of the toString() method.
`Real` `getReal()` Get a Real representing the number of seconds since * the epoch.
`static void` `main(String[] args)` run 'java visad.DateTime' to test the DateTime class
`static Gridded1DDoubleSet` `makeTimeSet(DateTime[] times)` Create a Gridded1DDoubleSet from an array of DateTimes
`static Gridded1DDoubleSet` `makeTimeSet(double[] times)` Create a Gridded1DDoubleSet from an array of doubles of seconds since the epoch.
`static void` `resetFormat()` Reset the format of the output of the toString() method to the default - yyyy-MM-dd HH:mm:ssZ (ex: 1999-05-04 15:27:08Z) and the TimeZone to UTC.
`static void` `setDateFormatClass(Class dateFormatClass)` You can override the DateFormat by specifying a class.
`static void` `setFormatPattern(String pattern)` Set the format of the output of the toString() method.
`static void` `setFormatTimeZone(TimeZone tz)` Set the TimeZone of the output of the toString() method.
`static DateTime[]` `timeSetToArray(Gridded1DSet timeSet)` Create an array of DateTimes from a Gridded1DSet of times.
`String` `timeString()` Return a string representing the "time" portion of this DateTime
`String` `toString()` Return a string representation of this DateTime.
`String` `toValueString()` Gets a string that represents just the value portion of this DateTime -- but with full semantics.

Methods inherited from class visad.Real
`__eq__, __eq__, __float__, __ge__, __ge__, __gt__, __gt__, __int__, __le__, __le__, __long__, __lt__, __lt__, __ne__, __ne__, adjustSamplingError, binary, cloneButUnit, cloneButValue, computeRanges, equals, getError, getUnit, getValue, getValue, hashCode, isMissing, longString, unary`

Methods inherited from class visad.Scalar
`addReference, clone, removeReference`

Methods inherited from class visad.DataImpl

`__add__, __add__, __div__, __div__, __mod__, __mod__, __mul__, __mul__, __neg__, __pow__, __pow__, __radd__, __rdiv__, __rmod__, __rmul__, __rpow__, __rsub__, __sub__, __sub__, abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, binary, ceil, ceil, changeMathType, computeRanges, computeRanges, computeReferenceRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, invertOp, local, log, log, longString, max, max, min, min, multiply, multiply, negate, negate, notifyReferences, pow, pow, remainder, remainder, rint, rint, round, round, setParent, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees, unary`

Methods inherited from class visad.ThingImpl
`adaptedAddReference, adaptedRemoveReference`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface visad.Data

`abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, binary, ceil, ceil, changeMathType, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, local, log, log, longString, max, max, min, min, multiply, multiply, negate, negate, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees, unary`

Methods inherited from interface visad.Thing
`addReference, removeReference`

Field Detail

### DEFAULT_TIME_FORMAT

    public static final String DEFAULT_TIME_FORMAT

  Default Time Format Pattern (yyyy-MM-dd HH:mm:ss)

  See Also:
    Constant Field Values

### DEFAULT_TIMEZONE

    public static final TimeZone DEFAULT_TIMEZONE

  Default Time Zone (GMT)

Constructor Detail

### DateTime

    public DateTime(Real real)
             throws VisADException

  Construct a DateTime object and initialize it using a VisAD Real. Unless the units of the Real specify otherwise, the Real's value is assumed to be seconds since the Epoch (i.e. 1970-01-01 00:00:00Z).

Parameters:
  `real` - Real value in a temporal unit.
Throws:
  `VisADException` - unit conversion problem

### DateTime

    public DateTime(double seconds)
             throws VisADException

  Construct a DateTime object and initialize it with the seconds since January 1, 1970 00:00:00Z.

Parameters:
  `seconds` - number of seconds since 1970-01-01 00:00:00Z.
Throws:
  `VisADException` - unit conversion problem

### DateTime

    public DateTime(double timeValue,
                    Unit timeUnits)
             throws VisADException

  Construct a DateTime object from a tim value and a Unit

Parameters:
  `timeValue` - value of time in timeUnits
  `timeUnits` - units of value

### DateTime

    public DateTime(Date date)
             throws VisADException

  Construct a DateTime object and initialize it with a Java date.

Parameters:
  `date` - date object
Throws:
  `VisADException` - unit conversion problem

### DateTime

    public DateTime()
             throws VisADException

  Construct a DateTime object and initialize it to the current date/time.

Throws:
  `VisADException` - unit conversion problem

### DateTime

    public DateTime(int year,
                    int day,
                    double seconds)
             throws VisADException

  Construct a DateTime object initialized with a year, day of the year, and seconds in the day.

Parameters:
  `year` - year - use negative year to indicated BC
  `day` - day of the year
  `seconds` - seconds in the day
Throws:
  `VisADException` - invalid day or seconds. Days must be greater than zero and seconds must be greater than zero and less than or equal to the seconds in a day.

Method Detail

### fromYearDaySeconds

    public static Real fromYearDaySeconds(int year,
                                          int day,
                                          double seconds)
                                   throws VisADException

  Return a Real object whose value is the seconds since the Epoch initialized with a year, day of the year, and seconds in the day.

  Parameters:
    `year` - year - use negative year to indicated BC
    `day` - day of the year
    `seconds` - seconds in the day
  Throws:
    `VisADException` - invalid day or seconds. Days must be greater than zero and seconds must be greater than zero and less than or equal to the seconds in a day.

### getReal

    public Real getReal()

  Get a Real representing the number of seconds since * the epoch.

  Returns:
    this object

### toString

    public String toString()

  Return a string representation of this DateTime. Unless the setFormatPattern() and/or setTimeZone() methods were used, the default it the ISO 8601 complete date plus hours, minutes and seconds and a time zone of UTC. See http://www.w3.org/TR/NOTE-datetime

  Specified by:
    `toString` in interface `RealIface`
  Overrides:
    `toString` in class `Real`
  Returns:
    String representing the date/time. Default is yyyy-MM-dd HH:mm:ssZ (ex: 1999-05-04 15:27:08Z)
  See Also:
    `setFormatPattern(java.lang.String)`, `setFormatTimeZone(java.util.TimeZone)`

### toValueString

    public String toValueString()

  Gets a string that represents just the value portion of this DateTime -- but with full semantics.

  Specified by:
    `toValueString` in interface `RealIface`
  Overrides:
    `toValueString` in class `Real`
  Returns:
    String representing the date/time in the form yyyy-MM-dd HH:mm:ssZ (ex: 1999-05-04 15:27:08Z)

### formattedString

    public String formattedString(String pattern,
                                  TimeZone timezone)

  Return a string representation of this DateTime from a user specified format. The pattern uses the time format syntax of java.text.SimpleDateFormat and the time zone is any of the valid java.util.TimeZone values.

  Parameters:
    `pattern` - time format string
    `timezone` - time zone to use
  Returns:
    String representing the date/time in the form specified by the pattern.
  See Also:
    `SimpleDateFormat`, `TimeZone`

### dateString

    public String dateString()

  Return a string representing the "date" portion of this DateTime

  Returns:
    String representing the date (UTC) in the form yyyy-MM-dd (ex: 1999-05-04).

### timeString

    public String timeString()

  Return a string representing the "time" portion of this DateTime

  Returns:
    String representing the time (UTC) in the form HH:mm:ssZ (ex: 15:27:08Z)

### setDateFormatClass

    public static void setDateFormatClass(Class dateFormatClass)

  You can override the DateFormat by specifying a class.

  Parameters:
    `dateFormatClass` - The class. This must be derived from java.text.DateFormat

### setFormatPattern

    public static void setFormatPattern(String pattern)

  Set the format of the output of the toString() method. All DateTime objects created in the JVM once this is set will use the new format so be very careful in your use of this method. The pattern uses the time format syntax of java.text.SimpleDateFormat.

  Parameters:
    `pattern` - time format string
  See Also:
    `If you want to use a time zone other than the default,`, `setFormatTimeZone(java.util.TimeZone)`

### getFormatPattern

    public static String getFormatPattern()

  Return the format pattern used in the output of the toString() method. The pattern uses the time format syntax of java.text.SimpleDateFormat.

  Returns:
    time format pattern
  See Also:
    `SimpleDateFormat`

### setFormatTimeZone

    public static void setFormatTimeZone(TimeZone tz)

  Set the TimeZone of the output of the toString() method. All DateTime objects created in the JVM once this is set will use the new TimeZone so be very careful in your use of this method. The time zone is any of the valid java.util.TimeZone values.

  Parameters:
    `tz` - time zone
  See Also:
    `TimeZone`

### getFormatTimeZone

    public static TimeZone getFormatTimeZone()

  Return the TimeZone used in the output of the toString() method.

  Returns:
    time zone

### resetFormat

    public static void resetFormat()

  Reset the format of the output of the toString() method to the default - yyyy-MM-dd HH:mm:ssZ (ex: 1999-05-04 15:27:08Z) and the TimeZone to UTC.

### createDateTime

    public static DateTime createDateTime(String dateString)
                                   throws VisADException

  Create a DateTime object from a string specification

  Parameters:
    `dateString` - date string specification in format pattern defined for DateTime in this JVM
  Throws:
    `VisADException` - formatting problem
  See Also:
    `setFormatPattern(java.lang.String)`

### createDateTime

    public static DateTime createDateTime(String dateString,
                                          String format)
                                   throws VisADException

  Create a DateTime object from a string specification using the supplied pattern and default timezone.

  Parameters:
    `dateString` - date string specification
    `format` - string
  Throws:
    `VisADException` - formatting problem

### createDateTime

    public static DateTime createDateTime(String dateString,
                                          String format,
                                          TimeZone timezone)
                                   throws VisADException

  Create a DateTime object from a string specification using the supplied pattern and timezone.

  Parameters:
    `dateString` - date string specification
    `timezone` - TimeZone to use
  Throws:
    `VisADException` - formatting problem

### compareTo

    public int compareTo(Object oo)

  Implement Comparable interface

  Specified by:
    `compareTo` in interface `RealIface`
  Overrides:
    `compareTo` in class `Real`
  Parameters:
    `oo` - Object for comparison - should be DateTime
  Returns:
    A negative integer, zero, or a positive integer depending on whether this Real is considered less than, equal to, or greater than the other Real, respectively. If the values of the Real-s in the default unit are equal, then the `ErrorEstimate.compareTo()` method is used to break the tie.

### makeTimeSet

    public static Gridded1DDoubleSet makeTimeSet(DateTime[] times)
                                          throws VisADException

  Create a Gridded1DDoubleSet from an array of DateTimes

  Parameters:
    `times` - array of DateTimes. Array cannot be null or only have one entry.
  Returns:
    Gridded1DDouble set representing the array
  Throws:
    `VisADException` - couldn't create the GriddedDoubleSet

### makeTimeSet

    public static Gridded1DDoubleSet makeTimeSet(double[] times)
                                          throws VisADException

  Create a Gridded1DDoubleSet from an array of doubles of seconds since the epoch.

  Parameters:
    `times` - array of times in seconds since the epoch. Array cannot be null or only have one entry.
  Returns:
    set representing the array as a Gridded1DDoubleSet
  Throws:
    `VisADException` - couldn't create the GriddedDoubleSet

### timeSetToArray

    public static DateTime[] timeSetToArray(Gridded1DSet timeSet)
                                     throws VisADException

  Create an array of DateTimes from a Gridded1DSet of times.

  Parameters:
    `timeSet` - Gridded1DSet of times
  Throws:
    `VisADException` - invalid time set or couldn't create DateTimes

### main

    public static void main(String[] args)
                     throws VisADException

  run 'java visad.DateTime' to test the DateTime class

  Throws:
    `VisADException`