public Object setDate(String privateCreator, int tag, VR vr, DatePrecision precision, Date... ds) { return set(privateCreator, tag, vr, vr.toValue(ds, getTimeZone(), precision)); }
public Object setDateRange(String privateCreator, int tag, VR vr, DatePrecision precision, DateRange range) { return set(privateCreator, tag, vr, toString(range, vr, getTimeZone(), precision)); }
public TimeZone getTimeZone() { if (tz != null) return tz; if (containsTimezoneOffsetFromUTC) { String s = getString(Tag.TimezoneOffsetFromUTC); if (s != null) try { tz = DateUtils.timeZone(s); } catch (IllegalArgumentException e) { LOG.info(e.getMessage()); } } else if (parent != null) return parent.getTimeZone(); else tz = getDefaultTimeZone(); return tz; }
private void updateTimezone(TimeZone from, TimeZone to) { for (int i = 0; i < size; i++) { Object val = values[i]; if (val instanceof Sequence) { Sequence new_name = (Sequence) val; for (Attributes item : new_name) { item.updateTimezone(item.getTimeZone(), to); item.remove(Tag.TimezoneOffsetFromUTC); } } else if (vrs[i] == VR.TM || vrs[i] == VR.DT) updateTimezone(from, to, i); } }
/** * Set Timezone Offset From UTC (0008,0201) to specified value and * adjust contained DA, DT and TM attributs accordingly * * @param utcOffset offset from UTC as (+|-)HHMM */ public void setTimezoneOffsetFromUTC(String utcOffset) { TimeZone tz = DateUtils.timeZone(utcOffset); updateTimezone(getTimeZone(), tz); setString(Tag.TimezoneOffsetFromUTC, VR.SH, utcOffset); }
public Date getDate(String privateCreator, long tag, Date defVal, DatePrecision precision) { int daTag = (int) (tag >>> 32); int tmTag = (int) tag; String tm = getString(privateCreator, tmTag, VR.TM, null); if (tm == null) return getDate(daTag, defVal, precision); String da = getString(privateCreator, daTag, VR.DA, null); if (da == null) return defVal; try { return VR.DT.toDate(da + tm, getTimeZone(), 0, false, null, precision); } catch (IllegalArgumentException e) { LOG.info("Invalid value of {} DA or {} TM", TagUtils.toString(daTag), TagUtils.toString(tmTag)); return defVal; } }
private DateRange toDateRange(String s, VR vr) { String[] range = splitRange(s); TimeZone tz = getTimeZone(); DatePrecision precision = new DatePrecision(); Date start = range[0] == null ? null : vr.toDate(range[0], tz, 0, false, null, precision); Date end = range[1] == null ? null : vr.toDate(range[1], tz, 0, true, null, precision); return new DateRange(start, end); }
public Date getDate(String privateCreator, int tag, VR vr, int valueIndex, Date defVal, DatePrecision precision) { int index = indexOf(privateCreator, tag); if (index < 0) return defVal; Object value = values[index]; if (value == Value.NULL) return defVal; if (vr == null) vr = vrs[index]; else updateVR(index, vr); if (!vr.isTemporalType()) { LOG.info("Attempt to access {} {} as date", TagUtils.toString(tag), vr); return defVal; } try { value = decodeStringValue(index); if (value == Value.NULL) return defVal; return vr.toDate(value, getTimeZone(), valueIndex, false, defVal, precision); } catch (IllegalArgumentException e) { LOG.info("Invalid value of {} {}", TagUtils.toString(tag), vr); return defVal; } }
public Date[] getDates(String privateCreator, int tag, VR vr, DatePrecisions precisions) { int index = indexOf(privateCreator, tag); if (index < 0) return null; Object value = values[index]; if (value == Value.NULL) return DateUtils.EMPTY_DATES; if (vr == null) vr = vrs[index]; else updateVR(index, vr); if (!vr.isTemporalType()) { LOG.info("Attempt to access {} {} as date", TagUtils.toString(tag), vr); return DateUtils.EMPTY_DATES; } try { value = decodeStringValue(index); if (value == Value.NULL) return DateUtils.EMPTY_DATES; return vr.toDates(value, getTimeZone(), false, precisions); } catch (IllegalArgumentException e) { LOG.info("Invalid value of {} {}", TagUtils.toString(tag), vr); return DateUtils.EMPTY_DATES; } }
public Date[] getDates(String privateCreator, long tag, DatePrecisions precisions) { int daTag = (int) (tag >>> 32); int tmTag = (int) tag; String[] tm = getStrings(privateCreator, tmTag); if (tm == null || tm.length == 0) return getDates(daTag, precisions); String[] da = getStrings(privateCreator, daTag); if (da == null || da.length == 0) return DateUtils.EMPTY_DATES; Date[] dates = new Date[da.length]; precisions.precisions = new DatePrecision[da.length]; int i = 0; try { TimeZone tz = getTimeZone(); while (i < tm.length) dates[i++] = VR.DT.toDate(da[i] + tm[i], tz, 0, false, null, precisions.precisions[i] = new DatePrecision()); while (i < da.length) dates[i++] = VR.DA.toDate(da[i], tz, 0, false, null, precisions.precisions[i] = new DatePrecision()); } catch (IllegalArgumentException e) { LOG.info("Invalid value of {} DA or {} TM", TagUtils.toString(daTag), TagUtils.toString(tmTag)); dates = Arrays.copyOf(dates, i); } return dates; }
/** * Set the Default Time Zone to specified value and adjust contained DA, * DT and TM attributs accordingly. If the Time Zone does not use Daylight * Saving Time, attribute Timezone Offset From UTC (0008,0201) will be also * set accordingly. If the Time zone uses Daylight Saving Time, a previous * existing attribute Timezone Offset From UTC (0008,0201) will be removed. * * @param tz Time Zone * * @see #setDefaultTimeZone(TimeZone) * @see #setTimezoneOffsetFromUTC(String) */ public void setTimezone(TimeZone tz) { updateTimezone(getTimeZone(), tz); if (tz.useDaylightTime()) { remove(Tag.TimezoneOffsetFromUTC); setDefaultTimeZone(tz); } else { setString(Tag.TimezoneOffsetFromUTC, VR.SH, DateUtils.formatTimezoneOffsetFromUTC(tz)); } this.tz=null; }
if (dateRange != null) if (dateRange.contains( vr.toDate(val, getTimeZone(), 0, false, null, new DatePrecision()))) return true; else