Package ca.uhn.fhir.model.primitive
Class DateDt
- 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.DateDt
-
- All Implemented Interfaces:
IDatatype,IElement,IIdentifiableElement,IPrimitiveDatatype<Date>,ISupportsUndeclaredExtensions,Externalizable,Serializable,IBase,IBaseDatatype,IPrimitiveType<Date>
public class DateDt extends BaseDateTimeDt
Represents a FHIR date datatype. Valid precisions values for this type are:Note on using Java Date objects: This type stores the date as a Java Date. Note that the Java Date has more precision (millisecond precision), and does not store a timezone. As such, it could potentially cause issues. For example, if a Date contains the number of milliseconds at midnight in a timezone across the date line from your location, it might refer to a different date than intended.
As such, it is recommended to use the
Calendarorint,int,intconstructors- 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 DateDt()ConstructorDateDt(int theYear, int theMonth, int theDay)Constructor which accepts a date value and uses theDEFAULT_PRECISIONfor this type.DateDt(String theDate)Constructor which accepts a date as a string in FHIR formatDateDt(Calendar theCalendar)Constructor which accepts a date value and uses theDEFAULT_PRECISIONfor this type.DateDt(Date theDate)Constructor which accepts a date value and uses theDEFAULT_PRECISIONfor this type.DateDt(Date theDate, TemporalPrecisionEnum thePrecision)Constructor which accepts a date value and a precision value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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 type-
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
-
DateDt
public DateDt()
Constructor
-
DateDt
public DateDt(Calendar theCalendar)
Constructor which accepts a date value and uses theDEFAULT_PRECISIONfor this type.
-
DateDt
public DateDt(Date theDate)
Constructor which accepts a date value and uses theDEFAULT_PRECISIONfor this type. Please see the note on timezones on theclass documentationfor considerations when using this constructor!
-
DateDt
public DateDt(Date theDate, TemporalPrecisionEnum thePrecision)
Constructor which accepts a date value and a precision value. Valid precisions values for this type are: Please see the note on timezones on theclass documentationfor considerations when using this constructor!- Throws:
DataFormatException- If the specified precision is not allowed for this type
-
DateDt
public DateDt(int theYear, int theMonth, int theDay)
Constructor which accepts a date value and uses theDEFAULT_PRECISIONfor this type.- Parameters:
theYear- The year, e.g. 2015theMonth- The month, e.g. 0 for JanuarytheDay- The day (1 indexed) e.g. 1 for the first day of the month
-
DateDt
public DateDt(String theDate)
Constructor which accepts a date as a string in FHIR format- Throws:
DataFormatException- If the precision in the date string is not allowed for this type
-
-
Method Detail
-
getDefaultPrecisionForDatatype
protected TemporalPrecisionEnum getDefaultPrecisionForDatatype()
Returns the default precision for this datatype- Specified by:
getDefaultPrecisionForDatatypein classBaseDateTimeDt- See Also:
DEFAULT_PRECISION
-
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
-
-