## org.h2.util
Class DateTimeUtils

    java.lang.Object
      org.h2.util.DateTimeUtils

    public class DateTimeUtils

extends java.lang.Object

This utility class contains time conversion functions.

Method Summary
`static java.sql.Date` `cloneAndNormalizeDate(java.sql.Date value)` Clone a date object and reset the hour, minutes, seconds, and milliseconds to zero.
`static java.sql.Time` `cloneAndNormalizeTime(java.sql.Time value)` Clone a time object and reset the day to 1970-01-01.
`static java.sql.Date` `convertDateToCalendar(java.sql.Date x, java.util.Calendar calendar)` Convert the date to the specified time zone.
`static Value` `convertDateToUniversal(java.sql.Date x, java.util.Calendar source)` Convert the date from the specified time zone to UTC.
`static java.sql.Timestamp` `convertTimestampToCalendar(java.sql.Timestamp x, java.util.Calendar calendar)` Convert the timestamp to the specified time zone.
`static Value` `convertTimestampToUniversal(java.sql.Timestamp x, java.util.Calendar source)` Convert the timestamp from the specified time zone to UTC.
`static java.sql.Time` `convertTimeToCalendar(java.sql.Time x, java.util.Calendar calendar)` Convert the time to the specified time zone.
`static Value` `convertTimeToUniversal(java.sql.Time x, java.util.Calendar source)` Convert the time from the specified time zone to UTC.
`static int` `getDatePart(java.util.Date d, int field)` Get the specified field of a date, however with years normalized to positive or negative, and month starting with 1.
`static long` `getTimeGMT(long millis)` Convert the number of milliseconds since 1970-01-01 in the local timezone to GMT.
`static long` `getTimeLocal(java.util.Date d)` Get the number of milliseconds since 1970-01-01 in the local timezone.
`static java.util.Date` `parseDateTime(java.lang.String original, int type, int errorCode)` Parse a date, time or timestamp value.
`static void` `resetCalendar()` Reset the calendar, for example after changing the default timezone.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### resetCalendar

    public static void resetCalendar()

  Reset the calendar, for example after changing the default timezone.

### convertTimestampToCalendar

    public static java.sql.Timestamp convertTimestampToCalendar(java.sql.Timestamp x,
                                                                java.util.Calendar calendar)
                                                         throws java.sql.SQLException

  Convert the timestamp to the specified time zone.

  Parameters:
    `x` - the timestamp
    `calendar` - the calendar
  Returns:
    the timestamp using the correct time zone
  Throws:
    `java.sql.SQLException`

### cloneAndNormalizeTime

    public static java.sql.Time cloneAndNormalizeTime(java.sql.Time value)

  Clone a time object and reset the day to 1970-01-01.

  Parameters:
    `value` - the time value
  Returns:
    the time value without the date component

### cloneAndNormalizeDate

    public static java.sql.Date cloneAndNormalizeDate(java.sql.Date value)

  Clone a date object and reset the hour, minutes, seconds, and milliseconds to zero.

  Parameters:
    `value` - the date value
  Returns:
    the date value at midnight

### convertDateToUniversal

    public static Value convertDateToUniversal(java.sql.Date x,
                                               java.util.Calendar source)
                                        throws java.sql.SQLException

  Convert the date from the specified time zone to UTC.

  Parameters:
    `x` - the date
    `source` - the calendar
  Returns:
    the date in UTC
  Throws:
    `java.sql.SQLException`

### convertTimeToUniversal

    public static Value convertTimeToUniversal(java.sql.Time x,
                                               java.util.Calendar source)
                                        throws java.sql.SQLException

  Convert the time from the specified time zone to UTC.

  Parameters:
    `x` - the time
    `source` - the calendar
  Returns:
    the time in UTC
  Throws:
    `java.sql.SQLException`

### convertTimestampToUniversal

    public static Value convertTimestampToUniversal(java.sql.Timestamp x,
                                                    java.util.Calendar source)
                                             throws java.sql.SQLException

  Convert the timestamp from the specified time zone to UTC.

  Parameters:
    `x` - the time
    `source` - the calendar
  Returns:
    the timestamp in UTC
  Throws:
    `java.sql.SQLException`

### convertDateToCalendar

    public static java.sql.Date convertDateToCalendar(java.sql.Date x,
                                                      java.util.Calendar calendar)
                                               throws java.sql.SQLException

  Convert the date to the specified time zone.

  Parameters:
    `x` - the date
    `calendar` - the calendar
  Returns:
    the date using the correct time zone
  Throws:
    `java.sql.SQLException`

### convertTimeToCalendar

    public static java.sql.Time convertTimeToCalendar(java.sql.Time x,
                                                      java.util.Calendar calendar)
                                               throws java.sql.SQLException

  Convert the time to the specified time zone.

  Parameters:
    `x` - the time
    `calendar` - the calendar
  Returns:
    the time using the correct time zone
  Throws:
    `java.sql.SQLException`

### parseDateTime

    public static java.util.Date parseDateTime(java.lang.String original,
                                               int type,
                                               int errorCode)
                                        throws java.sql.SQLException

  Parse a date, time or timestamp value. This method supports the format +/-year-month-day hour:minute:seconds.fractional and an optional timezone part.

  Parameters:
    `original` - the original string
    `type` - the value type (Value.TIME, TIMESTAMP, or DATE)
    `errorCode` - the error code to use if an error occurs
  Returns:
    the date object
  Throws:
    `java.sql.SQLException`

### getDatePart

    public static int getDatePart(java.util.Date d,
                                  int field)

  Get the specified field of a date, however with years normalized to positive or negative, and month starting with 1.

  Parameters:
    `d` - the date
    `field` - the field type
  Returns:
    the value

### getTimeLocal

    public static long getTimeLocal(java.util.Date d)

  Get the number of milliseconds since 1970-01-01 in the local timezone.

  Parameters:
    `d` - the date
  Returns:
    the milliseconds

### getTimeGMT

    public static long getTimeGMT(long millis)

  Convert the number of milliseconds since 1970-01-01 in the local timezone to GMT.

  Parameters:
    `millis` - the number of milliseconds in the local timezone
  Returns:
    the number of milliseconds in GMT