Interface IonTimestamp
timestamp value.
WARNING: This interface should not be implemented or extended by code outside of this library.
-
Field Summary
Fields inherited from interface com.amazon.ion.IonValue
EMPTY_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a copy of this value and all of its children.Gets the value of this Iontimestampas a JavaDate, representing the time in UTC.Gets the value of this Iontimestampas the number of milliseconds since 1970-01-01T00:00:00Z, including fractional milliseconds.Gets the local offset (in minutes) of this timestamp, ornullif it's unknown (i.e.,-00:00).longGets the value of this Iontimestampas the number of milliseconds since 1970-01-01T00:00:00.000Z, truncating any fractional milliseconds.voidmakeNull()Sets this timestamp to Ionnull.timestamp.voidSets the time portion of this timestamp to the current time, leaving the local offset portion unchanged.voidSets the time portion of this timestamp to the current time, and the local offset portion to UTC.voidsetDecimalMillis(BigDecimal millis) Sets this timestamp to represent the point in time that ismillismilliseconds after 1970-01-01T00:00:00Z, with the same local offset part.voidsetLocalOffset(int minutes) Sets the local-offset portion of this timestamp.voidsetLocalOffset(Integer minutes) Sets the local-offset portion of this timestamp.voidsetMillis(long millis) Sets this timestamp to represent the point in time that ismillismilliseconds after 1970-01-01T00:00:00Z, with the same local offset part.voidsetMillisUtc(long millis) Sets this timestamp to represent the point in time that ismillismilliseconds after 1970-01-01T00:00:00Z, and sets the local offset to UTC.voidSets the time portion of this timestamp.voidSets this timestamp to represent the point in time that ismillismilliseconds after 1970-01-01T00:00:00Z, with the specified local offset oflocalOffset.voidSets the value of thistimestamp.voidsetValue(BigDecimal millis, Integer localOffset) Sets this timestamp to represent the point in time that ismillismilliseconds after 1970-01-01T00:00:00Z, with the specified local offset oflocalOffset.Gets the value of thistimestampin a form suitable for use independent of Ion data.Methods inherited from interface com.amazon.ion.IonValue
accept, addTypeAnnotation, clearTypeAnnotations, equals, getContainer, getFieldId, getFieldName, getFieldNameSymbol, getSymbolTable, getSystem, getType, getTypeAnnotations, getTypeAnnotationSymbols, hashCode, hasTypeAnnotation, isNullValue, isReadOnly, makeReadOnly, removeFromContainer, removeTypeAnnotation, setTypeAnnotations, setTypeAnnotationSymbols, topLevelValue, toPrettyString, toString, toString, writeTo
-
Method Details
-
timestampValue
Timestamp timestampValue()Gets the value of thistimestampin a form suitable for use independent of Ion data.- Returns:
- the value of this timestamp,
or
nullifthis.isNullValue().
-
dateValue
Date dateValue()Gets the value of this Iontimestampas a JavaDate, representing the time in UTC. As a result, this method will return the same result for all Ion representations of the same instant, regardless of the local offset.Because
Dateinstances are mutable, this method returns a new instance from each call.- Returns:
- a new
Datevalue, in UTC, ornullifthis.isNullValue().
-
getMillis
Gets the value of this Iontimestampas the number of milliseconds since 1970-01-01T00:00:00.000Z, truncating any fractional milliseconds. This method will return the same result for all Ion representations of the same instant, regardless of the local offset.- Returns:
- the number of milliseconds since 1970-01-01T00:00:00.000Z represented by this timestamp.
- Throws:
NullValueException- ifthis.isNullValue().
-
getDecimalMillis
BigDecimal getDecimalMillis()Gets the value of this Iontimestampas the number of milliseconds since 1970-01-01T00:00:00Z, including fractional milliseconds. This method will return the same result for all Ion representations of the same instant, regardless of the local offset.- Returns:
- the number of milliseconds since 1970-01-01T00:00:00Z
represented by this timestamp,
or
nullifthis.isNullValue().
-
setValue
Sets the value of thistimestamp.- Parameters:
timestamp- may benullto cause this to benull.timestamp.
-
setValue
Sets this timestamp to represent the point in time that ismillismilliseconds after 1970-01-01T00:00:00Z, with the specified local offset oflocalOffset.- Parameters:
millis- the number of milliseconds since 1970-01-01T00:00:00Z to be represented by this timestamp.localOffset- the local offset of this timestamp, in minutes. Zero indicates UTC.nullindicates the unknown offset (-00:00).- Throws:
IllegalArgumentException- if the resulting timestamp would precede 0001-01-01T00:00:00Z.NullPointerException- ifmillisisnull
-
setValue
Sets this timestamp to represent the point in time that ismillismilliseconds after 1970-01-01T00:00:00Z, with the specified local offset oflocalOffset.- Parameters:
millis- the number of milliseconds since 1970-01-01T00:00:00Z to be represented by this timestamp.localOffset- the local offset of this timestamp, in minutes. Zero indicates UTC.nullindicates the unknown offset (-00:00).- Throws:
IllegalArgumentException- if the resulting timestamp would precede 0001-01-01T00:00:00Z.
-
setMillis
void setMillis(long millis) Sets this timestamp to represent the point in time that ismillismilliseconds after 1970-01-01T00:00:00Z, with the same local offset part.If this is
null.timestamp, then the local offset will be unknown.- Parameters:
millis- the number of milliseconds since 1970-01-01T00:00:00Z to be represented by this timestamp.- Throws:
IllegalArgumentException- if the resulting timestamp would precede 0001-01-01T00:00:00Z.
-
setDecimalMillis
Sets this timestamp to represent the point in time that ismillismilliseconds after 1970-01-01T00:00:00Z, with the same local offset part.If this is
null.timestamp, then the local offset will be unknown.- Parameters:
millis- the number of milliseconds since 1970-01-01T00:00:00Z to be represented by this timestamp.- Throws:
IllegalArgumentException- if the resulting timestamp would precede 0001-01-01T00:00:00Z.NullPointerException- ifmillisisnull
-
setMillisUtc
void setMillisUtc(long millis) Sets this timestamp to represent the point in time that ismillismilliseconds after 1970-01-01T00:00:00Z, and sets the local offset to UTC.- Parameters:
millis- the number of milliseconds since 1970-01-01T00:00:00Z to be represented by this timestamp.
-
getLocalOffset
Gets the local offset (in minutes) of this timestamp, ornullif it's unknown (i.e.,-00:00).For example, the result for
1969-02-23T07:00+07:00is 420, the result for1969-02-22T22:45:00.00-01:15is -75, and the result for1969-02-23(by Ion's definition, equivalent to1969-02-23T00:00-00:00) isnull.- Returns:
- the positive or negative local-time offset, represented as
minutes from UTC. If the offset is unknown, returns
null. - Throws:
NullValueException- ifthis.isNullValue().
-
setTime
Sets the time portion of this timestamp. Ifvalueisnull, then this will becomenull.timestamp. If this isnull.timestamp, then the local offset will be unknown.- Parameters:
value- will be copied into this element. If null then this becomesnull.timestamp.
-
setCurrentTime
void setCurrentTime()Sets the time portion of this timestamp to the current time, leaving the local offset portion unchanged.If
this.isNullValue(), then the local offset will be unknown. -
setCurrentTimeUtc
void setCurrentTimeUtc()Sets the time portion of this timestamp to the current time, and the local offset portion to UTC. -
setLocalOffset
Sets the local-offset portion of this timestamp. The time portion is not changed. Note that this method cannot set the unknown offset (-00:00); to do that usesetLocalOffset(Integer).- Parameters:
minutes- is the new local offset, in minutes. Zero indicates UTC.- Throws:
NullValueException- ifthis.isNullValue().
-
setLocalOffset
Sets the local-offset portion of this timestamp. The time portion is not changed.- Parameters:
minutes- is the new local offset, in minutes. Zero indicates UTC.nullindicates the unknown offset (-00:00).- Throws:
NullValueException- ifthis.isNullValue().
-
makeNull
void makeNull()Sets this timestamp to Ionnull.timestamp. -
clone
Description copied from interface:IonValueCreates a copy of this value and all of its children. The cloned value may use the same shared symbol tables, but it will have an independent local symbol table if necessary. The cloned value will be modifiable regardless of whether this instanceIonValue.isReadOnly().The cloned value will be created in the context of the same
ValueFactoryas this instance; if you want a copy using a different factory, then useValueFactory.clone(IonValue)instead.- Specified by:
clonein interfaceIonValue- Throws:
UnknownSymbolException- if any part of this value has unknown text but known Sid for its field name, annotation or symbol.
-