Package com.amazon.ion
Interface IonTimestamp
-
-
Field Summary
-
Fields inherited from interface com.amazon.ion.IonValue
EMPTY_ARRAY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IonTimestampclone()Creates a copy of this value and all of its children.java.util.DatedateValue()Gets the value of this Iontimestampas a JavaDate, representing the time in UTC.java.math.BigDecimalgetDecimalMillis()Gets the value of this Iontimestampas the number of milliseconds since 1970-01-01T00:00:00Z, including fractional milliseconds.java.lang.IntegergetLocalOffset()Gets the local offset (in minutes) of this timestamp, ornullif it's unknown (i.e.,-00:00).longgetMillis()Gets 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.voidsetCurrentTime()Sets the time portion of this timestamp to the current time, leaving the local offset portion unchanged.voidsetCurrentTimeUtc()Sets the time portion of this timestamp to the current time, and the local offset portion to UTC.voidsetDecimalMillis(java.math.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(java.lang.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.voidsetTime(java.util.Date value)Sets the time portion of this timestamp.voidsetValue(long millis, java.lang.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.voidsetValue(Timestamp timestamp)Sets the value of thistimestamp.voidsetValue(java.math.BigDecimal millis, java.lang.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.TimestamptimestampValue()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 Detail
-
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
java.util.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
long getMillis() throws NullValueExceptionGets 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
java.math.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
void setValue(Timestamp timestamp)
Sets the value of thistimestamp.- Parameters:
timestamp- may benullto cause this to benull.timestamp.
-
setValue
void setValue(java.math.BigDecimal millis, java.lang.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.- 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:
java.lang.IllegalArgumentException- if the resulting timestamp would precede 0001-01-01T00:00:00Z.java.lang.NullPointerException- ifmillisisnull
-
setValue
void setValue(long millis, java.lang.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.- 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:
java.lang.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:
java.lang.IllegalArgumentException- if the resulting timestamp would precede 0001-01-01T00:00:00Z.
-
setDecimalMillis
void setDecimalMillis(java.math.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.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:
java.lang.IllegalArgumentException- if the resulting timestamp would precede 0001-01-01T00:00:00Z.java.lang.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
java.lang.Integer getLocalOffset() throws NullValueExceptionGets 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
void setTime(java.util.Date value)
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
void setLocalOffset(int minutes) throws NullValueExceptionSets 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
void setLocalOffset(java.lang.Integer minutes) throws NullValueExceptionSets 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
IonTimestamp clone() throws UnknownSymbolException
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.
-
-