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:
- 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(Object o)
int
getMinutesOffset()
Returns this DateTimeOffset object's offset value.OffsetDateTime
getOffsetDateTime()
Returns OffsetDateTime equivalent to this DateTimeOffset object.Timestamp
getTimestamp()
Returns this DateTimeOffset object's timestamp value.int
hashCode()
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(Timestamp timestamp, int minutesOffset)
Converts a java.sql.Timestamp value with an integer offset to the equivalent DateTimeOffset valuestatic DateTimeOffset
valueOf(Timestamp timestamp, Calendar calendar)
Converts a java.sql.Timestamp value with a Calendar value to the equivalent DateTimeOffset value
-
-
-
Method Detail
-
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 valueminutesOffset
- 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 valuecalendar
- 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.
-
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 interfaceComparable<DateTimeOffset>
- Returns:
- a negative integer, zero, or a positive integer as this DateTimeOffset is less than, equal to, or greater than the specified DateTimeOffset.
-
-