public class PrecisionDate extends Object implements PreciseDate
A Java Time ZonedDateTime that also holds a Precision type indicating the accuracy of the date.
| Constructor and Description |
|---|
PrecisionDate()
Create a Date with a Precision
The default constructor creates dates with seconds precision, ie:yyyyMMddHHmmssZ |
PrecisionDate(long timeInMilliseconds)
Constructed with a default precision of seconds
|
PrecisionDate(Precision timePrecision)
Constructed with a default precision of seconds
|
PrecisionDate(Precision timePrecision,
long timeInMilliseconds)
Construct a date with the specified precision
|
PrecisionDate(Precision timePrecision,
ZonedDateTime date)
* Construct a date with the specified precision equivalent to this(timePrecision,
date.getTime())
|
| Modifier and Type | Method and Description |
|---|---|
ZonedDateTime |
getDateTime() |
Precision |
getPrecision() |
static PreciseDate |
today()
Convenience method to return the current date with DAY precision
|
String |
toNarrativeForm()
Return a string representation using the narrative form of formatter specified
in the Precision
|
String |
toString()
A String representation using only the required precision in HL7 ISO 8601 format
|
public PrecisionDate()
For other precise date use Precision(Precision p) or Precision(Precision p, long timeInMilliseconds)
Precisionpublic PrecisionDate(long timeInMilliseconds)
timeInMilliseconds - the milliseconds since January 1, 1970, 00:00:00 GMT.System.currentTimeMillis()public PrecisionDate(Precision timePrecision, long timeInMilliseconds)
timeInMilliseconds - the milliseconds since January 1, 1970, 00:00:00 GMT.timePrecision - the amount of time to use. eg: Precision.day indicating that hours,
minutes and seconds are to be ignoredSystem.currentTimeMillis()public PrecisionDate(Precision timePrecision, ZonedDateTime date)
timePrecision - the amount of time to use. eg: Precision.day indicating that hours,
minutes and seconds are to be ignoredSystem.currentTimeMillis()public PrecisionDate(Precision timePrecision)
System.currentTimeMillis()public static PreciseDate today()
public Precision getPrecision()
getPrecision in interface PreciseDatepublic String toString()
For example, a PrecisionDate with a Precision.Day accuracy will print yyyyMMdd while a PrecisionDate with a Precision.Millisecond with a millisecond accuracy will print yyyyMMddHHmmss.SSSZ
public ZonedDateTime getDateTime()
getDateTime in interface PreciseDatepublic String toNarrativeForm()
PreciseDatetoNarrativeForm in interface PreciseDateCopyright © 2021. All rights reserved.