public static Date[] toLocalDates(Object array) { if (array != null && array.getClass().isArray()) { Date[] dates = new Date[Array.getLength(array)]; for (int i = 0; i < dates.length; i++) { dates[i] = toLocalDate((TemporalAccessor) Array.get(array, i)); } return dates; } return null; }
public static TemporalAccessor getDateFromDicomElement(TagType type, Attributes dicom, int tag, String privateCreatorID, TemporalAccessor defaultValue) { if (dicom == null || !dicom.containsValue(tag)) { return defaultValue; } Date date = dicom.getDate(privateCreatorID, tag); if (date == null) { return defaultValue; } if (TagType.DICOM_DATE == type) { return TagUtil.toLocalDate(date); } else if (TagType.DICOM_TIME == type) { return TagUtil.toLocalTime(date); } return TagUtil.toLocalDateTime(date); }
|| TagType.DICOM_DATETIME.equals(type)) { if (val instanceof TemporalAccessor) { dataset.setDate(id, dic.vrOf(id), TagUtil.toLocalDate((TemporalAccessor) val)); } else if (val.getClass().isArray()) { dataset.setDate(id, dic.vrOf(id), TagUtil.toLocalDates(val));
public static TemporalAccessor[] getDatesFromDicomElement(TagType type, Attributes dicom, int tag, String privateCreatorID, TemporalAccessor[] defaultValue) { if (dicom == null || !dicom.containsValue(tag)) { return defaultValue; } Date[] dates = dicom.getDates(privateCreatorID, tag); if (dates == null || dates.length == 0) { return defaultValue; } TemporalAccessor[] vals; if (TagType.DICOM_DATE == type) { vals = new LocalDate[dates.length]; for (int i = 0; i < vals.length; i++) { vals[i] = TagUtil.toLocalDate(dates[i]); } } else if (TagType.DICOM_TIME == type) { vals = new LocalTime[dates.length]; for (int i = 0; i < vals.length; i++) { vals[i] = TagUtil.toLocalTime(dates[i]); } } vals = new LocalDateTime[dates.length]; for (int i = 0; i < vals.length; i++) { vals[i] = TagUtil.toLocalDateTime(dates[i]); } return vals; }
public static String getPatientAgeInPeriod(Attributes dicom, int tag, String privateCreatorID, String defaultValue, boolean computeOnlyIfNull) { if (dicom == null) { return defaultValue; } if (computeOnlyIfNull) { String s = dicom.getString(privateCreatorID, tag, defaultValue); if (StringUtil.hasText(s)) { return s; } } Date date = getDate(dicom, Tag.ContentDate, Tag.AcquisitionDate, Tag.DateOfSecondaryCapture, Tag.SeriesDate, Tag.StudyDate); if (date != null) { Date bithdate = dicom.getDate(Tag.PatientBirthDate); if (bithdate != null) { return getPeriod(TagUtil.toLocalDate(bithdate), TagUtil.toLocalDate(date)); } } return null; }