public class DateTimeAttribute extends StringAttribute
A concrete class specializing Attribute
for
Date Time (DT) attributes.
Though an instance of this class may be created
using its constructors, there is also a factory class, AttributeFactory
.
Attribute
,
AttributeFactory
,
AttributeList
Modifier and Type | Field and Description |
---|---|
protected static int |
MAX_LENGTH_SINGLE_VALUE |
specificCharacterSet
valueLength, valueMultiplicity
Constructor and Description |
---|
DateTimeAttribute(AttributeTag t)
Construct an (empty) attribute.
|
DateTimeAttribute(AttributeTag t,
long vl,
DicomInputStream i)
Read an attribute from an input stream.
|
DateTimeAttribute(AttributeTag t,
java.lang.Long vl,
DicomInputStream i)
Read an attribute from an input stream.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
allowRepairOfIncorrectLength() |
protected boolean |
allowRepairOfInvalidCharacterReplacement() |
static java.lang.String |
getCurrentTimeZone()
Get a DICOM format
String time zone representation of the current timezone. |
static java.util.Date |
getDateFromFormattedString(AttributeList list,
AttributeTag dateTag,
AttributeTag timeTag)
Get a Java
Date from a DICOM format DT String value. |
static java.util.Date |
getDateFromFormattedString(java.lang.String dateString)
Get a Java
Date from a DICOM format DT String value. |
static java.lang.String |
getFormattedString(java.util.Date date,
java.util.TimeZone timezone)
Get a DICOM format DT
String value from a Java Date . |
static java.lang.String |
getFormattedString(java.util.Date date,
java.util.TimeZone timezone,
boolean tzSuffix)
Get a DICOM format DT
String value from a Java Date . |
static java.lang.String |
getFormattedStringDefaultTimeZone(java.util.Date date)
Get a DICOM format DT
String value from a Java Date . |
static java.lang.String |
getFormattedStringUTC(java.util.Date date)
Get a DICOM format DT
String value from a Java Date . |
int |
getMaximumLengthOfSingleValue() |
static long |
getTimeInMilliSecondsSinceEpoch(AttributeList list,
AttributeTag dateTag,
AttributeTag timeTag)
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by the combination of the DA and TM values of the specified pair of attributes.
|
static long |
getTimeInMilliSecondsSinceEpoch(java.lang.String dateTime)
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by the DT value.
|
static java.util.TimeZone |
getTimeZone(java.lang.String dicomTimeZone)
Get a Java
TimeZone from a DICOM format String time zone. |
static java.lang.String |
getTimeZone(java.util.TimeZone javaTimeZone,
java.util.Date javaDate)
Get a DICOM format
String time zone from a Java TimeZone on a particular Java Date . |
byte[] |
getVR()
Get the value representation of this attribute (DT).
|
boolean |
isCharacterInValueValid(int c) |
addValue, addValue, addValue, addValue, addValue, addValue, addValue, areCharactersInValuesValid, areLengthsOfValuesValid, areValuesWellFormed, flushCachedCopies, getByteValues, getDoubleValues, getFloatValues, getIntegerValues, getInvalidCharacterReplacement, getLongValues, getOriginalStringValues, getPadByte, getPaddedVL, getShortValues, getSpecificCharacterSet, getStringValues, isValid, removeValues, repairValues, setSpecificCharacterSet, toString, translateByteArrayToString, translateStringToByteArray, write
getByteValues, getDelimitedStringValuesOrDefault, getDelimitedStringValuesOrDefault, getDelimitedStringValuesOrDefault, getDelimitedStringValuesOrDefault, getDelimitedStringValuesOrDefault, getDelimitedStringValuesOrDefault, getDelimitedStringValuesOrEmptyString, getDelimitedStringValuesOrEmptyString, getDelimitedStringValuesOrEmptyString, getDelimitedStringValuesOrEmptyString, getDelimitedStringValuesOrEmptyString, getDelimitedStringValuesOrEmptyString, getDelimitedStringValuesOrNull, getDelimitedStringValuesOrNull, getDelimitedStringValuesOrNull, getDelimitedStringValuesOrNull, getDelimitedStringValuesOrNull, getDelimitedStringValuesOrNull, getDoubleValues, getDoubleValues, getElement, getFloatValues, getFloatValues, getGroup, getIntegerValues, getIntegerValues, getLengthOfEncodedValue, getLongValues, getLongValues, getSingleDoubleValueOrDefault, getSingleDoubleValueOrDefault, getSingleDoubleValueOrDefault, getSingleFloatValueOrDefault, getSingleFloatValueOrDefault, getSingleFloatValueOrDefault, getSingleIntegerValueOrDefault, getSingleIntegerValueOrDefault, getSingleIntegerValueOrDefault, getSingleLongValueOrDefault, getSingleLongValueOrDefault, getSingleLongValueOrDefault, getSingleStringValueOrDefault, getSingleStringValueOrDefault, getSingleStringValueOrDefault, getSingleStringValueOrDefault, getSingleStringValueOrDefault, getSingleStringValueOrDefault, getSingleStringValueOrEmptyString, getSingleStringValueOrEmptyString, getSingleStringValueOrEmptyString, getSingleStringValueOrEmptyString, getSingleStringValueOrEmptyString, getSingleStringValueOrEmptyString, getSingleStringValueOrNull, getSingleStringValueOrNull, getSingleStringValueOrNull, getSingleStringValueOrNull, getSingleStringValueOrNull, getSingleStringValueOrNull, getStringValues, getStringValues, getStringValues, getStringValues, getStringValues, getTag, getVL, getVM, getVRAsString, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValues, setValues, setValues, setValues, setValues, setValues, setValues, toString, writeBase
protected static final int MAX_LENGTH_SINGLE_VALUE
public DateTimeAttribute(AttributeTag t)
Construct an (empty) attribute.
t
- the tag of the attributepublic DateTimeAttribute(AttributeTag t, long vl, DicomInputStream i) throws java.io.IOException, DicomException
Read an attribute from an input stream.
t
- the tag of the attributevl
- the value length of the attributei
- the input streamjava.io.IOException
- if an I/O error occursDicomException
- if error in DICOM encodingpublic DateTimeAttribute(AttributeTag t, java.lang.Long vl, DicomInputStream i) throws java.io.IOException, DicomException
Read an attribute from an input stream.
t
- the tag of the attributevl
- the value length of the attributei
- the input streamjava.io.IOException
- if an I/O error occursDicomException
- if error in DICOM encodingprotected final boolean allowRepairOfIncorrectLength()
allowRepairOfIncorrectLength
in class StringAttribute
protected final boolean allowRepairOfInvalidCharacterReplacement()
allowRepairOfInvalidCharacterReplacement
in class StringAttribute
public static java.lang.String getCurrentTimeZone()
Get a DICOM format String
time zone representation of the current timezone.
E.g. from +0500 or -0700, the last component of a DateTime attribute value, or the value of the DICOM attribute TimezoneOffsetFromUTC.
String
time zone representing the current time zone on the current datepublic static java.util.Date getDateFromFormattedString(AttributeList list, AttributeTag dateTag, AttributeTag timeTag) throws java.text.ParseException, DicomException
Get a Java Date
from a DICOM format DT String
value.
Will use the TimezoneOffsetFromUTC if present in the AttributeList, else will assume UTC (not whatever the local time zone happens to be).
list
- the list containing the attributesdateTag
- the tag of the DA attributetimeTag
- the tag of the TM attributeDate
java.text.ParseException
- if incorrectly encodedDicomException
- if date attribute is missing or emptypublic static java.util.Date getDateFromFormattedString(java.lang.String dateString) throws java.text.ParseException
Get a Java Date
from a DICOM format DT String
value.
dateString
- the date to parseDate
java.text.ParseException
- if incorrectly encodedpublic static java.lang.String getFormattedString(java.util.Date date, java.util.TimeZone timezone)
Get a DICOM format DT String
value from a Java Date
.
Will format the Date for the specified timezone.
Will include the timezone suffix.
date
- the Java Date
to formattimezone
- the Java TimeZone
to usepublic static java.lang.String getFormattedString(java.util.Date date, java.util.TimeZone timezone, boolean tzSuffix)
Get a DICOM format DT String
value from a Java Date
.
Will format the Date for the specified timezone.
date
- the Java Date
to formattimezone
- the Java TimeZone
to usetzSuffix
- whether or not to append the time zone suffixpublic static java.lang.String getFormattedStringDefaultTimeZone(java.util.Date date)
Get a DICOM format DT String
value from a Java Date
.
Will format the Date for the default timezone, converting from whatever timezone is specified in the supplied Date
if not the default.
date
- the Java Date
to formatpublic static java.lang.String getFormattedStringUTC(java.util.Date date)
Get a DICOM format DT String
value from a Java Date
.
Will format the Date for the UTC timezone, converting from whatever timezone is specified in the supplied Date
if not UTC.
date
- the Java Date
to formatpublic final int getMaximumLengthOfSingleValue()
getMaximumLengthOfSingleValue
in class StringAttribute
public static long getTimeInMilliSecondsSinceEpoch(AttributeList list, AttributeTag dateTag, AttributeTag timeTag) throws java.text.ParseException, DicomException
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by the combination of the DA and TM values of the specified pair of attributes.
Will use the TimezoneOffsetFromUTC if present in the AttributeList, else will assume UTC (not whatever the local time zone happens to be).
list
- the list containing the attributesdateTag
- the tag of the DA attributetimeTag
- the tag of the TM attributejava.text.ParseException
- if incorrectly encodedDicomException
- if date attribute is missing or emptypublic static long getTimeInMilliSecondsSinceEpoch(java.lang.String dateTime) throws java.text.ParseException
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by the DT value.
dateTime
- the string to parsejava.text.ParseException
- if incorrectly encodedpublic static java.util.TimeZone getTimeZone(java.lang.String dicomTimeZone)
Get a Java TimeZone
from a DICOM format String
time zone.
E.g. from +0500 or -0700, the last component of a DateTime attribute value, or the value of the DICOM attribute TimezoneOffsetFromUTC.
dicomTimeZone
- the String
DICOM format time zoneTimeZone
representing the supplied time zone, or the GMT zone if it cannot be understoodpublic static java.lang.String getTimeZone(java.util.TimeZone javaTimeZone, java.util.Date javaDate)
Get a DICOM format String
time zone from a Java TimeZone
on a particular Java Date
.
E.g. from +0500 or -0700, the last component of a DateTime attribute value, or the value of the DICOM attribute TimezoneOffsetFromUTC.
javaTimeZone
- the TimeZone
time zonejavaDate
- the Date
used to establish whether daylight savings is in effect or notString
time zone representing the supplied time zone on the supplied datepublic byte[] getVR()
Get the value representation of this attribute (DT).
getVR
in class Attribute
ValueRepresentation
public final boolean isCharacterInValueValid(int c) throws DicomException
isCharacterInValueValid
in class StringAttribute
DicomException