TimeUtil
Date: 2018-05-01

com.mysql.jdbc

## Class TimeUtil

- java.lang.Object
- - com.mysql.jdbc.TimeUtil

-     public class TimeUtil
      extends java.lang.Object

  Timezone conversion routines and other time related methods

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) static java.util.TimeZone` | `GMT_TIMEZONE`
    `protected static java.lang.reflect.Method` | `systemNanoTimeMethod`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimeUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.sql.Timestamp` | `changeTimezone(MySQLConnection conn, java.util.Calendar sessionCalendar, java.util.Calendar targetCalendar, java.sql.Timestamp tstamp, java.util.TimeZone fromTz, java.util.TimeZone toTz, boolean rollForward)` Change the given timestamp from one timezone to another
    `static java.sql.Time` | `changeTimezone(MySQLConnection conn, java.util.Calendar sessionCalendar, java.util.Calendar targetCalendar, java.sql.Time t, java.util.TimeZone fromTz, java.util.TimeZone toTz, boolean rollForward)` Change the given times from one timezone to another
    `(package private) static java.sql.Date` | `fastDateCreate(boolean useGmtConversion, java.util.Calendar gmtCalIfNeeded, java.util.Calendar cal, int year, int month, int day)`
    `(package private) static java.sql.Date` | `fastDateCreate(int year, int month, int day, java.util.Calendar targetCalendar)`
    `(package private) static java.sql.Time` | `fastTimeCreate(java.util.Calendar cal, int hour, int minute, int second, ExceptionInterceptor exceptionInterceptor)`
    `(package private) static java.sql.Time` | `fastTimeCreate(int hour, int minute, int second, java.util.Calendar targetCalendar, ExceptionInterceptor exceptionInterceptor)`
    `(package private) static java.sql.Timestamp` | `fastTimestampCreate(boolean useGmtConversion, java.util.Calendar gmtCalIfNeeded, java.util.Calendar cal, int year, int month, int day, int hour, int minute, int seconds, int secondsPart)`
    `(package private) static java.sql.Timestamp` | `fastTimestampCreate(java.util.TimeZone tz, int year, int month, int day, int hour, int minute, int seconds, int secondsPart)`
    `static java.lang.String` | `formatNanos(int nanos, boolean serverSupportsFracSecs, boolean usingMicros)`
    `static java.lang.String` | `getCanonicalTimezone(java.lang.String timezoneStr, ExceptionInterceptor exceptionInterceptor)` Returns the 'official' Java timezone name for the given timezone
    `static long` | `getCurrentTimeNanosOrMillis()`
    `static java.util.TimeZone` | `getDefaultTimeZone(boolean useCache)`
    `static boolean` | `nanoTimeAvailable()`
    `static java.sql.Timestamp` | `truncateFractionalSeconds(java.sql.Timestamp timestamp)`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### GMT_TIMEZONE

          static final java.util.TimeZone GMT_TIMEZONE

    - #### systemNanoTimeMethod

          protected static final java.lang.reflect.Method systemNanoTimeMethod

  - ### Constructor Detail

    - #### TimeUtil

          public TimeUtil()

  - ### Method Detail

    - #### nanoTimeAvailable

          public static boolean nanoTimeAvailable()

    - #### getDefaultTimeZone

          public static final java.util.TimeZone getDefaultTimeZone(boolean useCache)

    - #### getCurrentTimeNanosOrMillis

          public static long getCurrentTimeNanosOrMillis()

    - #### changeTimezone

          public static java.sql.Time changeTimezone(MySQLConnection conn,
                                     java.util.Calendar sessionCalendar,
                                     java.util.Calendar targetCalendar,
                                     java.sql.Time t,
                                     java.util.TimeZone fromTz,
                                     java.util.TimeZone toTz,
                                     boolean rollForward)

      Change the given times from one timezone to another
      Parameters:
        `conn` - the current connection to the MySQL server
        `t` - the times to change
        `fromTz` - the timezone to change from
        `toTz` - the timezone to change to
      Returns:
        the times changed to the timezone 'toTz'

    - #### changeTimezone

          public static java.sql.Timestamp changeTimezone(MySQLConnection conn,
                                          java.util.Calendar sessionCalendar,
                                          java.util.Calendar targetCalendar,
                                          java.sql.Timestamp tstamp,
                                          java.util.TimeZone fromTz,
                                          java.util.TimeZone toTz,
                                          boolean rollForward)

      Change the given timestamp from one timezone to another
      Parameters:
        `conn` - the current connection to the MySQL server
        `tstamp` - the timestamp to change
        `fromTz` - the timezone to change from
        `toTz` - the timezone to change to
      Returns:
        the timestamp changed to the timezone 'toTz'

    - #### fastDateCreate

          static final java.sql.Date fastDateCreate(boolean useGmtConversion,
                                     java.util.Calendar gmtCalIfNeeded,
                                     java.util.Calendar cal,
                                     int year,
                                     int month,
                                     int day)

    - #### fastDateCreate

          static final java.sql.Date fastDateCreate(int year,
                                     int month,
                                     int day,
                                     java.util.Calendar targetCalendar)

    - #### fastTimeCreate

          static final java.sql.Time fastTimeCreate(java.util.Calendar cal,
                                     int hour,
                                     int minute,
                                     int second,
                                     ExceptionInterceptor exceptionInterceptor)
                                             throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### fastTimeCreate

          static final java.sql.Time fastTimeCreate(int hour,
                                     int minute,
                                     int second,
                                     java.util.Calendar targetCalendar,
                                     ExceptionInterceptor exceptionInterceptor)
                                             throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### fastTimestampCreate

          static final java.sql.Timestamp fastTimestampCreate(boolean useGmtConversion,
                                               java.util.Calendar gmtCalIfNeeded,
                                               java.util.Calendar cal,
                                               int year,
                                               int month,
                                               int day,
                                               int hour,
                                               int minute,
                                               int seconds,
                                               int secondsPart)

    - #### fastTimestampCreate

          static final java.sql.Timestamp fastTimestampCreate(java.util.TimeZone tz,
                                               int year,
                                               int month,
                                               int day,
                                               int hour,
                                               int minute,
                                               int seconds,
                                               int secondsPart)

    - #### getCanonicalTimezone

          public static java.lang.String getCanonicalTimezone(java.lang.String timezoneStr,
                                              ExceptionInterceptor exceptionInterceptor)
                                                       throws java.sql.SQLException

      Returns the 'official' Java timezone name for the given timezone
      Parameters:
        `timezoneStr` - the 'common' timezone name
      Returns:
        the Java timezone name for the given timezone
      Throws:
        `java.sql.SQLException`
        `java.lang.IllegalArgumentException`

    - #### formatNanos

          public static java.lang.String formatNanos(int nanos,
                                     boolean serverSupportsFracSecs,
                                     boolean usingMicros)

    - #### truncateFractionalSeconds

          public static java.sql.Timestamp truncateFractionalSeconds(java.sql.Timestamp timestamp)