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>
public class InstantDt extends BaseDateTimeDt
Represents a FHIR instant datatype. Valid precisions values for this type are:- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static TemporalPrecisionEnumDEFAULT_PRECISIONThe default precision for this type-
Fields inherited from class ca.uhn.fhir.model.primitive.BaseDateTimeDt
NOW_DATE_CONSTANT
-
-
Constructor Summary
Constructors Constructor Description InstantDt()Constructor which creates an InstantDt with no timne value.InstantDt(BaseDateTimeDt theDateTime)Create a new DateTimeDt using an existing value.InstantDt(String theString)Create a new InstantDt from a string valueInstantDt(Calendar theCalendar)Create a new DateTimeDtInstantDt(Date theDate)Create a new DateTimeDt with the given date/time andTemporalPrecisionEnum.MILLIprecisionInstantDt(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanafter(Date theDate)InvokesDate.after(Date)on the contained Date against the given datebooleanbefore(Date theDate)InvokesDate.before(Date)on the contained Date against the given dateprotected TemporalPrecisionEnumgetDefaultPrecisionForDatatype()Returns the default precision for this datatypeprotected booleanisPrecisionAllowed(TemporalPrecisionEnum thePrecision)To be implemented by subclasses to indicate whether the given precision is allowed by this typevoidsetToCurrentTimeInLocalTimeZone()Sets the value of this instant to the current time (from the system clock) and the local/default timezone (as retrieved usingTimeZone.getDefault().static InstantDtwithCurrentTime()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 Detail
-
DEFAULT_PRECISION
public static final TemporalPrecisionEnum DEFAULT_PRECISION
The default precision for this type
-
-
Constructor Detail
-
InstantDt
public InstantDt()
-
InstantDt
public InstantDt(Date theDate, TemporalPrecisionEnum thePrecision, TimeZone theTimezone)
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
public InstantDt(BaseDateTimeDt theDateTime)
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
public InstantDt(Date theDate)
Create a new DateTimeDt with the given date/time andTemporalPrecisionEnum.MILLIprecision
-
InstantDt
public InstantDt(Date theDate, TemporalPrecisionEnum thePrecision)
Constructor which accepts a date value and a precision value. Valid precisions values for this type are:
-
InstantDt
public InstantDt(String theString)
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 Detail
-
after
public boolean after(Date theDate)
InvokesDate.after(Date)on the contained Date against the given date- Throws:
NullPointerException- If thecontained Dateis null
-
before
public boolean before(Date theDate)
InvokesDate.before(Date)on the contained Date against the given date- Throws:
NullPointerException- If thecontained Dateis null
-
setToCurrentTimeInLocalTimeZone
public void 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
protected boolean isPrecisionAllowed(TemporalPrecisionEnum thePrecision)
Description copied from class:BaseDateTimeDtTo be implemented by subclasses to indicate whether the given precision is allowed by this type- Specified by:
isPrecisionAllowedin classBaseDateTimeDt
-
withCurrentTime
public static InstantDt withCurrentTime()
Factory method which creates a new InstantDt with millisecond precision and initializes it with the current time and the system local timezone.
-
getDefaultPrecisionForDatatype
protected TemporalPrecisionEnum getDefaultPrecisionForDatatype()
Returns the default precision for this datatype- Specified by:
getDefaultPrecisionForDatatypein classBaseDateTimeDt- See Also:
DEFAULT_PRECISION
-
-