Package microsoft.sql

Class DateTimeOffset

java.lang.Object
microsoft.sql.DateTimeOffset
All Implemented Interfaces:
Serializable, Comparable<DateTimeOffset>

public final class DateTimeOffset extends Object implements Serializable, 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:
  • Method Details

    • valueOf

      public static DateTimeOffset valueOf(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(Timestamp timestamp, 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 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 Object
      Returns:
      a String object in yyyy-mm-dd hh:mm:ss[.fffffffff] [+|-]hh:mm format
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public 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 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 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.