TagD extends TagW { public static String getDicomPeriod(String value) { if (!StringUtil.hasText(value)) { return StringUtil.EMPTY_STRING; } if (value.length() < 2) { return ""; } String unit; switch (value.charAt(value.length() - 1)) { case 'Y': unit = ChronoUnit.YEARS.toString(); break; case 'M': unit = ChronoUnit.MONTHS.toString(); break; case 'W': unit = ChronoUnit.WEEKS.toString(); break; case 'D': unit = ChronoUnit.DAYS.toString(); break; default: LOGGER.error("Get period format: \"{}\" is not valid", value); return StringUtil.EMPTY_STRING; } StringBuilder builder = new StringBuilder(value.substring(0, value.length() - 1).replaceFirst("^0+(?!$)", "")); builder.append(" "); builder.append(unit); return builder.toString(); } TagD(int tagID);  TagD(int tagID, int vmMax);  TagD(int tagID, int vmMin, int vmMax);  TagD(int tagID, int vmMin, int vmMax, Object defaultValue);  TagD(int tagID, String privateCreatorID);  TagD(int tagID, String privateCreatorID, int vmMin, int vmMax, Object defaultValue);  TagD(int tagID, String displayedName, String privateCreatorID, int vmMin, int vmMax, Object defaultValue);  TagD(int tagID, String keyword, String displayedName, String privateCreatorID, VR vr, int vmMin, int vmMax,
        Object defaultValue, boolean retired); private  TagD(int tagID, String displayedName, String privateCreatorID, VR vr, int vmMin, int vmMax,
        Object defaultValue); VR getValueRerpesentation(); int getDicomValueMultiplicity(Object value); @Override int hashCode(); @Override boolean equals(Object obj); @Override Object getValue(Object data); @Override boolean isStringFamilyType(); @Override String getFormattedTagValue(Object value, String format); static TagW get(String keyword); static String getKeywordFromTag(int tagID, String privateCreatorID); static TagW get(int tagID); static TagW get(int tagID, String privateCreatorID); static TagW getNullable(int tagID); static TagW getNullable(int tagID, String privateCreatorID); static Object getTagValue(TagReadable tagable, int tagID); static T getTagValue(TagReadable tagable, int tagID, Class<T> type); static TagW[] getTagFromIDs(int... tagID); static TagW getUID(Level level); static LocalDate getDicomDate(String date); static LocalTime getDicomTime(String time); static LocalDateTime getDicomDateTime(TimeZone tz, String value); static LocalDateTime getDicomDateTime(TimeZone tz, String value, boolean ceil); static LocalDateTime dateTime(long dateTimeID, Attributes attributes); static LocalDateTime dateTime(int dateID, int timeID, TagReadable tagable); static String formatDicomDate(LocalDate date); static String formatDicomTime(LocalTime time); static TemporalAccessor getDateFromElement(XMLStreamReader xmler, String attribute, TagType type,
        TemporalAccessor defaultValue); static TemporalAccessor[] getDatesFromElement(XMLStreamReader xmler, String attribute, TagType type,
        TemporalAccessor[] defaultValue); static TemporalAccessor[] getDatesFromElement(XMLStreamReader xmler, String attribute, TagType type,
        TemporalAccessor[] defaultValue, String separator); static String getDicomPeriod(String value); static String getDicomPersonName(String name); static String getDicomPatientSex(String val);  }
@Test public void testGetDicomPeriod() throws Exception { String period = TagD.getDicomPeriod(null); assertEquals("", period); period = TagD.getDicomPeriod("0"); assertEquals("", period); period = TagD.getDicomPeriod("0Z"); assertEquals("", period); period = TagD.getDicomPeriod("031Y"); assertEquals("31 " + ChronoUnit.YEARS.toString(), period); period = TagD.getDicomPeriod("001Y"); assertEquals("1 " + ChronoUnit.YEARS.toString(), period); period = TagD.getDicomPeriod("1Y"); assertEquals("1 " + ChronoUnit.YEARS.toString(), period); period = TagD.getDicomPeriod("000Y"); assertEquals("0 " + ChronoUnit.YEARS.toString(), period); period = TagD.getDicomPeriod("001M"); assertEquals("1 " + ChronoUnit.MONTHS.toString(), period); period = TagD.getDicomPeriod("011W"); assertEquals("11 " + ChronoUnit.WEEKS.toString(), period); period = TagD.getDicomPeriod("111D"); assertEquals("111 " + ChronoUnit.DAYS.toString(), period); }