Package oracle.nosql.driver.values
Class TimestampValue
java.lang.Object
oracle.nosql.driver.values.FieldValue
oracle.nosql.driver.values.TimestampValue
- All Implemented Interfaces:
Comparable<FieldValue>
A
FieldValue instance representing a timestamp value. TimestampValue
represents an instant in time in UTC. TimestampValue always stores its state
in UTC. Instances can be created from long values which represent the number
of milliseconds since the Epoch, 1970-01-01T00:00:00. They can also be
created from string values in a valid ISO 8601 format. String formats without
an explicit time zone are interpreted as UTC time.
TimestampValue is directly correlated to the database type of the same name and should be used during value construction for fields of that datatype.
-
Nested Class Summary
Nested classes/interfaces inherited from class oracle.nosql.driver.values.FieldValue
FieldValue.Type -
Constructor Summary
ConstructorsConstructorDescriptionTimestampValue(long millisecond) Creates a new instance from milliseconds since the Epoch.TimestampValue(String value) Creates a new instance using an ISO 8601 formatted string.TimestampValue(String value, String pattern, boolean useUTC) Creates a TimestampValue instance from a String with specified pattern.TimestampValue(Timestamp value) Creates a new instance from a JavaTimestamp -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(FieldValue other) booleanlonggetLong()Returns the long value of this object as the number of millisecond since the Epoch, 1970-01-01T00:00:00.Returns a BigDecimal value for this object based on its long value.Returns the string value of this object, it is in the ISO 8601 format "uuuu-MM-dd'T'HH:mm:ss[.f..f]" and the time zone is UTC.getType()Returns the type of the objectgetValue()Returns the JavaTimestampvalue of this objectinthashCode()toJson(JsonOptions options) Returns the JSON value of the instance.Methods inherited from class oracle.nosql.driver.values.FieldValue
asArray, asBinary, asBoolean, asDouble, asInteger, asJsonNull, asLong, asMap, asNull, asNumber, asString, asTimestamp, castAsDouble, createFromJson, createFromJson, createFromJson, getBinary, getBoolean, getDouble, getInt, getSerializedSize, getTimestamp, isAnyNull, isArray, isAtomic, isBinary, isBoolean, isDouble, isInteger, isJsonNull, isLong, isMap, isNull, isNumber, isNumeric, isString, isTimestamp, toJson, toString
-
Constructor Details
-
TimestampValue
public TimestampValue(long millisecond) Creates a new instance from milliseconds since the Epoch.- Parameters:
millisecond- the number of milliseconds since the Epoch, "1970-01-01T00:00:00".
-
TimestampValue
Creates a new instance using an ISO 8601 formatted string. If timezone is not specified it is interpreted as UTC.- Parameters:
value- the string of a Timestamp in ISO 8601 format "uuuu-MM-dd['T'HH:mm:ss[.f..f]]".
-
TimestampValue
Creates a TimestampValue instance from a String with specified pattern.- Parameters:
value- a timestamp string in the format of the specifiedpatternor the default pattern, "uuuu-MM-dd['T'HH:mm:ss[.f..f]]", which is used ifpatternis null.pattern- the pattern for the timestampString. If null, then default pattern "uuuu-MM-dd['T'HH:mm:ss[.f..f]]" is used to parse the string. The symbols that can be used to specify a pattern are described inDateTimeFormatter.useUTC- if true the UTC time zone is used as default zone when parsing the string, otherwise the local time zone is used. If the timestampString has zone information, then that zone will be used.- Throws:
IllegalArgumentException- if the string cannot be parsed with the the given pattern correctly.
-
TimestampValue
Creates a new instance from a JavaTimestamp- Parameters:
value- the Timestamp value
-
-
Method Details
-
getType
Description copied from class:FieldValueReturns the type of the object- Specified by:
getTypein classFieldValue- Returns:
- the type
-
getValue
Returns the JavaTimestampvalue of this object- Returns:
- the Timestamp value
-
getLong
public long getLong()Returns the long value of this object as the number of millisecond since the Epoch, 1970-01-01T00:00:00.- Overrides:
getLongin classFieldValue- Returns:
- the long value
-
getNumber
Returns a BigDecimal value for this object based on its long value.- Overrides:
getNumberin classFieldValue- Returns:
- the BigDecimal value
-
getString
Returns the string value of this object, it is in the ISO 8601 format "uuuu-MM-dd'T'HH:mm:ss[.f..f]" and the time zone is UTC.- Overrides:
getStringin classFieldValue- Returns:
- the string value
-
compareTo
-
toJson
Returns the JSON value of the instance. IfJsonOptions.getTimestampAsLong()is true it is returned as a simple long value; otherwise it is returned as a quoted string using the ISO 8601 format.- Overrides:
toJsonin classFieldValue- Parameters:
options- a JsonOptions instance to indicate non-default values, may be null.- Returns:
- the string value.
-
equals
-
hashCode
public int hashCode()
-