com.pixelmed.dicom
Class DateTimeAttribute

java.lang.Object
  extended by com.pixelmed.dicom.Attribute
      extended by com.pixelmed.dicom.StringAttribute
          extended by com.pixelmed.dicom.DateTimeAttribute

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.

See Also:
Attribute, AttributeFactory, AttributeList

Field Summary
 
Fields inherited from class com.pixelmed.dicom.StringAttribute
specificCharacterSet
 
Fields inherited from class com.pixelmed.dicom.Attribute
valueLength, valueMultiplicity
 
Constructor Summary
DateTimeAttribute(AttributeTag t)
          Construct 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
static Date getDateFromFormattedString(AttributeList list, AttributeTag dateTag, AttributeTag timeTag)
          Get a Java Date from a DICOM format DT String value.
static Date getDateFromFormattedString(String dateString)
          Get a Java Date from a DICOM format DT String value.
static String getFormattedString(Date date)
          Deprecated. use getFormattedStringDefaultTimeZone() instead
static String getFormattedString(Date date, TimeZone timezone)
          Get a DICOM format DT String value from a Java Date.
static String getFormattedString(Date date, TimeZone timezone, boolean tzSuffix)
          Get a DICOM format DT String value from a Java Date.
static String getFormattedStringDefaultTimeZone(Date date)
          Get a DICOM format DT String value from a Java Date.
static String getFormattedStringUTC(Date date)
          Get a DICOM format DT String value from a Java Date.
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)
          Get a Java TimeZone from a DICOM format String time zone.
 byte[] getVR()
          Get the value representation of this attribute (DT).
 
Methods inherited from class com.pixelmed.dicom.StringAttribute
addValue, addValue, addValue, addValue, addValue, addValue, addValue, getByteValues, getDoubleValues, getFloatValues, getIntegerValues, getLongValues, getOriginalStringValues, getPadByte, getPaddedVL, getShortValues, getSpecificCharacterSet, getStringValues, removeValues, setSpecificCharacterSet, toString, translateByteArrayToString, translateStringToByteArray, write
 
Methods inherited from class com.pixelmed.dicom.Attribute
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, 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, toString, writeBase
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateTimeAttribute

public DateTimeAttribute(AttributeTag t)

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 attribute
vl - the value length of the attribute
i - the input stream
Throws:
IOException
DicomException

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 attribute
vl - the value length of the attribute
i - the input stream
Throws:
IOException
DicomException
Method Detail

getVR

public byte[] getVR()

Get the value representation of this attribute (DT).

Overrides:
getVR in class Attribute
Returns:
'D','T' in ASCII as a two byte array; see ValueRepresentation

getFormattedString

public static String getFormattedString(Date date,
                                        TimeZone timezone,
                                        boolean tzSuffix)

Get a DICOM format DT String value from a Java Date.

Will format the Date for the specified timezone.

Parameters:
date - the Java Date to format
timezone - the Java TimeZone to use
tzSuffix - whether or not to append the time zone suffix
Returns:
a DICOM formatted DT value

getFormattedString

public static String getFormattedString(Date date,
                                        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.

Parameters:
date - the Java Date to format
timezone - the Java TimeZone to use
Returns:
a DICOM formatted DT value

getFormattedStringUTC

public static String getFormattedStringUTC(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.

Parameters:
date - the Java Date to format
Returns:
a DICOM formatted DT value

getFormattedStringDefaultTimeZone

public static String getFormattedStringDefaultTimeZone(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.

Parameters:
date - the Java Date to format
Returns:
a DICOM formatted DT value

getFormattedString

public static String getFormattedString(Date date)
Deprecated. use getFormattedStringDefaultTimeZone() instead

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.

Parameters:
date - the Java Date to format
Returns:
a DICOM formatted DT value

getDateFromFormattedString

public static Date getDateFromFormattedString(String dateString)
                                       throws ParseException

Get a Java Date from a DICOM format DT String value.

Parameters:
dateString - the date to parse
Returns:
a Java Date
Throws:
ParseException

getDateFromFormattedString

public static Date getDateFromFormattedString(AttributeList list,
                                              AttributeTag dateTag,
                                              AttributeTag timeTag)
                                       throws 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).

Parameters:
list - the list containing the attributes
dateTag - the tag of the DA attribute
timeTag - the tag of the TM attribute
Returns:
a Java Date
Throws:
ParseException
DicomException - if date attribute is missing or empty

getTimeZone

public static TimeZone getTimeZone(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.

Parameters:
dicomTimeZone - the String DICOM format time zone
Returns:
a Java TimeZone representing the supplied time zone, or the GMT zone if it cannot be understood

getTimeInMilliSecondsSinceEpoch

public static long getTimeInMilliSecondsSinceEpoch(String dateTime)
                                            throws ParseException

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

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 attributes
dateTag - the tag of the DA attribute
timeTag - 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
DicomException - if date attribute is missing or empty