Package ca.uhn.fhir.model.primitive
Class InstantDt
java.lang.Object
ca.uhn.fhir.model.api.BaseElement
ca.uhn.fhir.model.api.BaseIdentifiableElement
ca.uhn.fhir.model.api.BasePrimitive<Date>
ca.uhn.fhir.model.primitive.BaseDateTimeDt
ca.uhn.fhir.model.primitive.InstantDt
- All Implemented Interfaces:
IDatatype
,IElement
,IIdentifiableElement
,IPrimitiveDatatype<Date>
,ISupportsUndeclaredExtensions
,Externalizable
,Serializable
,IBase
,IBaseDatatype
,IPrimitiveType<Date>
Represents a FHIR instant datatype. Valid precisions values for this type are:
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final TemporalPrecisionEnum
The default precision for this typeFields inherited from class ca.uhn.fhir.model.primitive.BaseDateTimeDt
NOW_DATE_CONSTANT, TODAY_DATE_CONSTANT
-
Constructor Summary
ConstructorDescriptionConstructor which creates an InstantDt with no timne value.InstantDt
(BaseDateTimeDt theDateTime) Create a new DateTimeDt using an existing value.Create a new InstantDt from a string valueCreate a new DateTimeDtCreate a new DateTimeDt with the given date/time andTemporalPrecisionEnum.MILLI
precisionInstantDt
(Date theDate, TemporalPrecisionEnum thePrecision) Constructor which accepts a date value and a precision value.InstantDt
(Date theDate, TemporalPrecisionEnum thePrecision, TimeZone theTimezone) Create a new instance using the given date, precision level, and time zone -
Method Summary
Modifier and TypeMethodDescriptionboolean
InvokesDate.after(Date)
on the contained Date against the given dateboolean
InvokesDate.before(Date)
on the contained Date against the given dateprotected TemporalPrecisionEnum
Returns the default precision for this datatypeprotected boolean
isPrecisionAllowed
(TemporalPrecisionEnum thePrecision) To be implemented by subclasses to indicate whether the given precision is allowed by this typevoid
Sets the value of this instant to the current time (from the system clock) and the local/default timezone (as retrieved usingTimeZone.getDefault()
.static InstantDt
Factory method which creates a new InstantDt with millisecond precision and initializes it with the current time and the system local timezone.Methods inherited from class ca.uhn.fhir.model.primitive.BaseDateTimeDt
encode, getDay, getHour, getMillis, getMinute, getMonth, getNanos, getPrecision, getSecond, getTimeZone, getValueAsCalendar, getYear, isTimeZoneZulu, isToday, parse, setDay, setHour, setMillis, setMinute, setMonth, setNanos, setPrecision, setSecond, setTimeZone, setTimeZoneZulu, setValue, setValue, setValueAsString, setYear, toHumanDisplay, toHumanDisplayLocalTimezone
Methods inherited from class ca.uhn.fhir.model.api.BasePrimitive
equals, getValue, getValueAsString, hashCode, hasValue, isEmpty, readExternal, toString, updateStringValue, writeExternal
Methods inherited from class ca.uhn.fhir.model.api.BaseIdentifiableElement
getElementSpecificId, getId, setElementSpecificId, setId, setId
Methods inherited from class ca.uhn.fhir.model.api.BaseElement
addUndeclaredExtension, addUndeclaredExtension, addUndeclaredExtension, getAllUndeclaredExtensions, getFormatCommentsPost, getFormatCommentsPre, getUndeclaredExtensions, getUndeclaredExtensionsByUrl, getUndeclaredModifierExtensions, getUserData, hasFormatComment, isBaseEmpty, setUserData
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.hl7.fhir.instance.model.api.IBase
fhirType, getFormatCommentsPost, getFormatCommentsPre, getUserData, hasFormatComment, setUserData
-
Field Details
-
DEFAULT_PRECISION
The default precision for this type
-
-
Constructor Details
-
InstantDt
public InstantDt()Constructor which creates an InstantDt with no timne value. Note that unlike the default constructor for the JavaDate
orCalendar
objects, this constructor does not initialize the object with the current time.- See Also:
-
InstantDt
Create a new DateTimeDt -
InstantDt
Create a new instance using the given date, precision level, and time zone- Throws:
DataFormatException
- If the specified precision is not allowed for this type
-
InstantDt
Create a new DateTimeDt using an existing value. Use this constructor with caution, as it may create more precision than warranted (since for example it is possible to pass in a DateTime with only a year, and this constructor will convert to an InstantDt with milliseconds precision). -
InstantDt
Create a new DateTimeDt with the given date/time andTemporalPrecisionEnum.MILLI
precision -
InstantDt
Constructor which accepts a date value and a precision value. Valid precisions values for this type are: -
InstantDt
Create a new InstantDt from a string value- Parameters:
theString
- The string representation of the string. Must be in a valid format according to the FHIR specification- Throws:
DataFormatException
-
-
Method Details
-
after
InvokesDate.after(Date)
on the contained Date against the given date- Throws:
NullPointerException
- If thecontained Date
is null
-
before
InvokesDate.before(Date)
on the contained Date against the given date- Throws:
NullPointerException
- If thecontained Date
is null
-
setToCurrentTimeInLocalTimeZone
Sets the value of this instant to the current time (from the system clock) and the local/default timezone (as retrieved usingTimeZone.getDefault()
. This TimeZone is generally obtained from the underlying OS. -
isPrecisionAllowed
Description copied from class:BaseDateTimeDt
To be implemented by subclasses to indicate whether the given precision is allowed by this type- Specified by:
isPrecisionAllowed
in classBaseDateTimeDt
-
withCurrentTime
Factory method which creates a new InstantDt with millisecond precision and initializes it with the current time and the system local timezone. -
getDefaultPrecisionForDatatype
Returns the default precision for this datatype- Specified by:
getDefaultPrecisionForDatatype
in classBaseDateTimeDt
- See Also:
-