com.versionone

## Class DB.DateTime

- java.lang.Object
- - com.versionone.DB
  - - com.versionone.DB.DateTime

- All Implemented Interfaces:
    Comparable<DB.DateTime>
  Enclosing class:
    DB

      public static class DB.DateTime
      extends DB
      implements Comparable<DB.DateTime>

  DB Type for Dates

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class com.versionone.DB

      `DB.BigInt, DB.Bit, DB.DateTime, DB.Int, DB.NullObject, DB.Real, DB.Str`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static SimpleDateFormat` | `DAY_FORMAT`
    `static SimpleDateFormat` | `DAY_N_TIME_FORMAT`

    - ### Fields inherited from class com.versionone.DB

      `Null`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DateTime()` Default Construction (creates a null object)
    `DateTime(Date value)` Create and set value from a java.util.Date instance
    `DateTime(Object value)` Create and set value from an Object If Object is | Value set by String | Use a SimpleDateFormat object to parse string | Expected format is yyyy-MM-dd'T'HH:mm:ss in UTC Date | Set the date (same as DateTime(Date value)

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DB.DateTime` | `add(int field, int value)`
    `int` | `compareTo(DB.DateTime another)`
    `DB.DateTime` | `convertLocalToUtc()` Converts this DateTime object to UTC.
    `static Date` | `convertLocalToUtc(Date date)` Converts time in UTC timezone to local time.
    `DB.DateTime` | `convertUtcToLocal()` Converts this DateTime object to UTC.
    `static Date` | `convertUtcToLocal(Date date)` Converts time in local timezone to UTC time.
    `boolean` | `equals(Object obj)` Compare this instance to another instance of Db.DateTime or another Date object
    `DB.DateTime` | `getDate()` Gets the Date component of this instance.
    `Date` | `getValue()` Get the Date object or null if this instance is null
    `static DB.DateTime` | `now()`
    `Duration` | `subtract(DB.DateTime date)` Subtracts the specified date from this instance.
    `long` | `toLong()` return the long value of this date
    `String` | `toString()` return the String representation of this object

    - ### Methods inherited from class com.versionone.DB

      `hashCode, isNull`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DAY_N_TIME_FORMAT

          public static final SimpleDateFormat DAY_N_TIME_FORMAT

    - #### DAY_FORMAT

          public static final SimpleDateFormat DAY_FORMAT

  - ### Constructor Detail

    - #### DateTime

          public DateTime()

      Default Construction (creates a null object)

    - #### DateTime

          public DateTime(Date value)

      Create and set value from a java.util.Date instance
      Parameters:
        `value` - - value set from this object

    - #### DateTime

          public DateTime(Object value)

      Create and set value from an Object If Object is | Value set by String | Use a SimpleDateFormat object to parse string | Expected format is yyyy-MM-dd'T'HH:mm:ss in UTC Date | Set the date (same as DateTime(Date value)
      Parameters:
        `value` - - instance used to set value

  - ### Method Detail

    - #### now

          public static DB.DateTime now()

    - #### getValue

          public Date getValue()

      Get the Date object or null if this instance is null
      Specified by:
        `getValue` in class `DB`
      Returns:
        Object

    - #### equals

          public boolean equals(Object obj)

      Compare this instance to another instance of Db.DateTime or another Date object
      Specified by:
        `equals` in class `DB`

    - #### toLong

          public long toLong()

      return the long value of this date
      Returns:
        long
      See Also:
        `Date.getTime()`

    - #### toString

          public String toString()

      Description copied from class: `DB`
      return the String representation of this object
      Overrides:
        `toString` in class `DB`
      Returns:
        data in yyyy-MM-dd HH:mm:ss format

    - #### subtract

          public Duration subtract(DB.DateTime date)

      Subtracts the specified date from this instance.
      Parameters:
        `date` - specified date
      Returns:
        number of days between specified date and date from this instance

    - #### getDate

          public DB.DateTime getDate()

      Gets the Date component of this instance. If isNull() is true, returns itself.
      Returns:
        new object with same date but 0:00:00 time.

    - #### add

          public DB.DateTime add(int field,
                                 int value)

    - #### convertUtcToLocal

          public static Date convertUtcToLocal(Date date)

      Converts time in local timezone to UTC time.
      Parameters:
        `date` - to be converted
      Returns:
        new Date object representing the UTC time.

    - #### convertUtcToLocal

          public DB.DateTime convertUtcToLocal()

      Converts this DateTime object to UTC.
      Returns:
        new object representing UTC time.

    - #### convertLocalToUtc

          public static Date convertLocalToUtc(Date date)

      Converts time in UTC timezone to local time.
      Parameters:
        `date` - to be converted
      Returns:
        new Date object representing the local time.

    - #### convertLocalToUtc

          public DB.DateTime convertLocalToUtc()

      Converts this DateTime object to UTC.
      Returns:
        new object representing UTC time.

    - #### compareTo

          public int compareTo(DB.DateTime another)

      Specified by:
        `compareTo` in interface `Comparable<DB.DateTime>`

Copyright © 2016 VersionOne, Inc.. All rights reserved.