Package com.salesforce.datacloud.jdbc.util

## Class DateTimeUtils

- java.lang.Object
- - com.salesforce.datacloud.jdbc.util.DateTimeUtils

    public final class DateTimeUtils
    extends Object

Datetime utility functions.

### Field Summary

Fields
`static long` `MILLIS_TO_MICRO_SECS_CONVERSION_FACTOR`

### Method Summary

All Methods Static Methods Concrete Methods
`static LocalDateTime` `adjustForCalendar​(LocalDateTime localDateTime, Calendar calendar, TimeZone defaultTimeZone)` Adjusts LocalDateTime for the given Calendar's timezone offset.
`static long` `applyCalendarOffset​(long milliseconds)` Subtracts default Calendar's timezone offset from epoch milliseconds to get relative UTC milliseconds
`static long` `applyCalendarOffset​(long milliseconds, Calendar calendar)`
`static Date` `getUTCDateFromDateAndCalendar​(Date date, Calendar calendar)`
`static Date` `getUTCDateFromMilliseconds​(long milliseconds)`
`static Time` `getUTCTimeFromMilliseconds​(long milliseconds)`
`static Time` `getUTCTimeFromTimeAndCalendar​(Time time, Calendar calendar)`
`static Timestamp` `getUTCTimestampFromTimestampAndCalendar​(Timestamp timestamp, Calendar calendar)`
`static long` `localDateTimeToMicrosecondsSinceEpoch​(LocalDateTime localDateTime)` Converts LocalDateTime to microseconds since epoch.
`static long` `millisToMicrosecondsSinceMidnight​(long millis)` Converts milliseconds since midnight to microseconds since midnight.

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

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

### Field Detail

#### MILLIS_TO_MICRO_SECS_CONVERSION_FACTOR

    public static final long MILLIS_TO_MICRO_SECS_CONVERSION_FACTOR

See Also:
  Constant Field Values

### Method Detail

#### applyCalendarOffset

    public static long applyCalendarOffset​(long milliseconds)

Subtracts default Calendar's timezone offset from epoch milliseconds to get relative UTC milliseconds

#### applyCalendarOffset

    public static long applyCalendarOffset​(long milliseconds,
                                           Calendar calendar)

#### getUTCDateFromMilliseconds

    public static Date getUTCDateFromMilliseconds​(long milliseconds)

#### getUTCTimeFromMilliseconds

    public static Time getUTCTimeFromMilliseconds​(long milliseconds)

#### getUTCDateFromDateAndCalendar

    public static Date getUTCDateFromDateAndCalendar​(Date date,
                                                     Calendar calendar)

#### getUTCTimeFromTimeAndCalendar

    public static Time getUTCTimeFromTimeAndCalendar​(Time time,
                                                     Calendar calendar)

#### getUTCTimestampFromTimestampAndCalendar

    public static Timestamp getUTCTimestampFromTimestampAndCalendar​(Timestamp timestamp,
                                                                    Calendar calendar)

#### localDateTimeToMicrosecondsSinceEpoch

    public static long localDateTimeToMicrosecondsSinceEpoch​(LocalDateTime localDateTime)

Converts LocalDateTime to microseconds since epoch.

Parameters:
  `localDateTime` - The LocalDateTime to convert.
Returns:
  The microseconds since epoch.

#### millisToMicrosecondsSinceMidnight

    public static long millisToMicrosecondsSinceMidnight​(long millis)

Converts milliseconds since midnight to microseconds since midnight.

Parameters:
  `millis` - The milliseconds since midnight.
Returns:
  The microseconds since midnight.

#### adjustForCalendar

    public static LocalDateTime adjustForCalendar​(LocalDateTime localDateTime,
                                                  Calendar calendar,
                                                  TimeZone defaultTimeZone)

Adjusts LocalDateTime for the given Calendar's timezone offset.

Parameters:
  `localDateTime` - The LocalDateTime to adjust.
  `calendar` - The Calendar with the target timezone.
  `defaultTimeZone` - The default timezone to compare against.
Returns:
  The adjusted LocalDateTime.