Class DateTimeAttribute
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
.
- See Also:
-
Field Summary
FieldsFields inherited from class com.pixelmed.dicom.StringAttribute
specificCharacterSet
Fields inherited from class com.pixelmed.dicom.Attribute
valueLength, valueMultiplicity
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an (empty) attribute.DateTimeAttribute
(AttributeTag t, long vl, DicomInputStream i) Read an attribute from an input stream.DateTimeAttribute
(AttributeTag t, Long vl, DicomInputStream i) Read an attribute from an input stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected final boolean
protected final boolean
static String
Get a DICOM formatString
time zone representation of the current timezone.static Date
getDateFromFormattedString
(AttributeList list, AttributeTag dateTag, AttributeTag timeTag) static Date
getDateFromFormattedString
(String dateString) static String
getFormattedString
(Date date) static String
getFormattedString
(Date date, TimeZone timezone) static String
getFormattedString
(Date date, TimeZone timezone, boolean tzSuffix) static String
static String
getFormattedStringUTC
(Date date) final int
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
(String dateTime) Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by the DT value.static TimeZone
getTimeZone
(String dicomTimeZone) static String
getTimeZone
(TimeZone javaTimeZone, Date javaDate) byte[]
getVR()
Get the value representation of this attribute (DT).final boolean
isCharacterInValueValid
(int c) Methods inherited from class com.pixelmed.dicom.StringAttribute
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
Methods inherited from class com.pixelmed.dicom.Attribute
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, getLengthOfBaseOfEncodedAttribute, getLengthOfEncodedValue, getLengthOfEntireEncodedAttribute, 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
-
Field Details
-
MAX_LENGTH_SINGLE_VALUE
protected static final int MAX_LENGTH_SINGLE_VALUE- See Also:
-
-
Constructor Details
-
DateTimeAttribute
Construct an (empty) attribute.
- Parameters:
t
- the tag of the attribute
-
DateTimeAttribute
public DateTimeAttribute(AttributeTag t, long vl, DicomInputStream i) throws IOException, DicomException Read an attribute from an input stream.
- Parameters:
t
- the tag of the attributevl
- the value length of the attributei
- the input stream- Throws:
IOException
- if an I/O error occursDicomException
- if error in DICOM encoding
-
DateTimeAttribute
public DateTimeAttribute(AttributeTag t, Long vl, DicomInputStream i) throws IOException, DicomException Read an attribute from an input stream.
- Parameters:
t
- the tag of the attributevl
- the value length of the attributei
- the input stream- Throws:
IOException
- if an I/O error occursDicomException
- if error in DICOM encoding
-
-
Method Details
-
getMaximumLengthOfSingleValue
public final int getMaximumLengthOfSingleValue()- Specified by:
getMaximumLengthOfSingleValue
in classStringAttribute
-
getVR
public byte[] getVR()Get the value representation of this attribute (DT).
- Overrides:
getVR
in classAttribute
- Returns:
- 'D','T' in ASCII as a two byte array; see
ValueRepresentation
-
allowRepairOfIncorrectLength
protected final boolean allowRepairOfIncorrectLength()- Overrides:
allowRepairOfIncorrectLength
in classStringAttribute
-
allowRepairOfInvalidCharacterReplacement
protected final boolean allowRepairOfInvalidCharacterReplacement()- Overrides:
allowRepairOfInvalidCharacterReplacement
in classStringAttribute
-
isCharacterInValueValid
- Overrides:
isCharacterInValueValid
in classStringAttribute
- Throws:
DicomException
-
getFormattedString
-
getFormattedString
-
getFormattedStringUTC
Get a DICOM format DT
String
value from a JavaDate
.Will format the Date for the UTC timezone, converting from whatever timezone is specified in the supplied
Date
if not UTC.- Parameters:
date
- the JavaDate
to format- Returns:
- a DICOM formatted DT value
-
getFormattedStringDefaultTimeZone
Get a DICOM format DT
String
value from a JavaDate
.Will format the Date for the default timezone, converting from whatever timezone is specified in the supplied
Date
if not the default.- Parameters:
date
- the JavaDate
to format- Returns:
- a DICOM formatted DT value
-
getFormattedString
Get a DICOM format DT
String
value from a JavaDate
.Will format the Date for the default timezone, converting from whatever timezone is specified in the supplied
Date
if not the default.- Parameters:
date
- the JavaDate
to format- Returns:
- a DICOM formatted DT value
-
getDateFromFormattedString
- Parameters:
dateString
- the date to parse- Returns:
- a Java
Date
- Throws:
ParseException
- if incorrectly encoded
-
getDateFromFormattedString
public static Date getDateFromFormattedString(AttributeList list, AttributeTag dateTag, AttributeTag timeTag) throws ParseException, DicomException Get a Java
Date
from a DICOM format DTString
value.Will use the TimezoneOffsetFromUTC if present in the AttributeList, else will assume UTC (not whatever the local time zone happens to be).
- Parameters:
list
- the list containing the attributesdateTag
- the tag of the DA attributetimeTag
- the tag of the TM attribute- Returns:
- a Java
Date
- Throws:
ParseException
- if incorrectly encodedDicomException
- if date attribute is missing or empty
-
getTimeZone
-
getTimeZone
-
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.
- Returns:
- a DICOM format
String
time zone representing the current time zone on the current date
-
getTimeInMilliSecondsSinceEpoch
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by the DT value.
- Parameters:
dateTime
- the string to parse- Returns:
- the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date; may be a ludicrous value if string not formatted correctly
- Throws:
ParseException
- if incorrectly encoded
-
getTimeInMilliSecondsSinceEpoch
public static long getTimeInMilliSecondsSinceEpoch(AttributeList list, AttributeTag dateTag, AttributeTag timeTag) throws 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).
- Parameters:
list
- the list containing the attributesdateTag
- the tag of the DA attributetimeTag
- the tag of the TM attribute- Returns:
- the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date
- Throws:
ParseException
- if incorrectly encodedDicomException
- if date attribute is missing or empty
-