Package microsoft.sql

Class DateTimeOffset

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<DateTimeOffset>

    public final class DateTimeOffset
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable<DateTimeOffset>
    Represents the SQL Server DATETIMEOFFSET data type. The DateTimeOffset class represents a java.sql.Timestamp, including fractional seconds, plus an integer representing the number of minutes offset from GMT.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(DateTimeOffset other)
      Compares this DateTimeOffset object with another DateTimeOffset object to determine their relative order.
      boolean equals​(java.lang.Object o)  
      int getMinutesOffset()
      Returns this DateTimeOffset object's offset value.
      java.time.OffsetDateTime getOffsetDateTime()
      Returns OffsetDateTime equivalent to this DateTimeOffset object.
      java.sql.Timestamp getTimestamp()
      Returns this DateTimeOffset object's timestamp value.
      int hashCode()  
      java.lang.String toString()
      Formats a datetimeoffset as yyyy-mm-dd hh:mm:ss[.fffffffff] [+|-]hh:mm, where yyyy-mm-dd hh:mm:ss[.fffffffff] indicates a timestamp that is offset from UTC by the number of minutes indicated by [+|-]hh:mm.
      static DateTimeOffset valueOf​(java.sql.Timestamp timestamp, int minutesOffset)
      Converts a java.sql.Timestamp value with an integer offset to the equivalent DateTimeOffset value
      static DateTimeOffset valueOf​(java.sql.Timestamp timestamp, java.util.Calendar calendar)
      Converts a java.sql.Timestamp value with a Calendar value to the equivalent DateTimeOffset value
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • valueOf

        public static DateTimeOffset valueOf​(java.sql.Timestamp timestamp,
                                             int minutesOffset)
        Converts a java.sql.Timestamp value with an integer offset to the equivalent DateTimeOffset value
        Parameters:
        timestamp - A java.sql.Timestamp value
        minutesOffset - An integer offset in minutes
        Returns:
        The DateTimeOffset value of the input timestamp and minutesOffset
      • valueOf

        public static DateTimeOffset valueOf​(java.sql.Timestamp timestamp,
                                             java.util.Calendar calendar)
        Converts a java.sql.Timestamp value with a Calendar value to the equivalent DateTimeOffset value
        Parameters:
        timestamp - A java.sql.Timestamp value
        calendar - A java.util.Calendar value
        Returns:
        The DateTimeOffset value of the input timestamp and calendar
      • toString

        public java.lang.String toString()
        Formats a datetimeoffset as yyyy-mm-dd hh:mm:ss[.fffffffff] [+|-]hh:mm, where yyyy-mm-dd hh:mm:ss[.fffffffff] indicates a timestamp that is offset from UTC by the number of minutes indicated by [+|-]hh:mm.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String object in yyyy-mm-dd hh:mm:ss[.fffffffff] [+|-]hh:mm format
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getTimestamp

        public java.sql.Timestamp getTimestamp()
        Returns this DateTimeOffset object's timestamp value.

        The returned value represents an instant in time as the number of milliseconds since January 1, 1970, 00:00:00 GMT.

        Returns:
        this DateTimeOffset object's timestamp component
      • getOffsetDateTime

        public java.time.OffsetDateTime getOffsetDateTime()
        Returns OffsetDateTime equivalent to this DateTimeOffset object.
        Returns:
        OffsetDateTime equivalent to this DateTimeOffset object.
      • getMinutesOffset

        public int getMinutesOffset()
        Returns this DateTimeOffset object's offset value.
        Returns:
        this DateTimeOffset object's minutes offset from GMT
      • compareTo

        public int compareTo​(DateTimeOffset other)
        Compares this DateTimeOffset object with another DateTimeOffset object to determine their relative order.

        The ordering is based on the timestamp component only. The offset component is not compared. Two DateTimeOffset objects are considered equivalent with respect to ordering as long as they represent the same moment in time, regardless of the location of the event. This is how SQL Server orders DATETIMEOFFSET values.

        Specified by:
        compareTo in interface java.lang.Comparable<DateTimeOffset>
        Returns:
        a negative integer, zero, or a positive integer as this DateTimeOffset is less than, equal to, or greater than the specified DateTimeOffset.