EncodingSchemeUtils { public static DCMIPeriod decodePeriod(DublinCoreValue value) { return decodePeriod(value.getValue()); } private  EncodingSchemeUtils(); static DublinCoreValue encodeDate(Date date, Precision precision); static String formatDate(Date date, Precision precision); static DublinCoreValue encodePeriod(DCMIPeriod period, Precision precision); static DublinCoreValue encodeDuration(long duration); static Long decodeDuration(String value); static Long decodeDuration(DublinCoreValue value); static Long decodeMandatoryDuration(String value); static Date decodeDate(DublinCoreValue value); static Date decodeDate(String value); static Date decodeMandatoryDate(DublinCoreValue value); static Date decodeMandatoryDate(String value); static DCMIPeriod decodePeriod(DublinCoreValue value); static DCMIPeriod decodePeriod(String value); static DCMIPeriod decodeMandatoryPeriod(DublinCoreValue value); static DCMIPeriod decodeMandatoryPeriod(String value); static Temporal decodeTemporal(DublinCoreValue value); static Temporal decodeMandatoryTemporal(DublinCoreValue value);  }
@Test public void testDecodePeriod() { DCMIPeriod a = decodePeriod(DublinCoreValue.mk("start=2008-10-01; end=2009-01-01;")); assertEquals(createDate(2008, 10, 1, 0, 0, 0), a.getStart()); assertEquals(createDate(2009, 1, 1, 0, 0, 0), a.getEnd()); DCMIPeriod b = decodePeriod(DublinCoreValue.mk("start=2008-10-01; end=2009-01-01")); assertEquals(createDate(2008, 10, 1, 0, 0, 0), b.getStart()); assertEquals(createDate(2009, 1, 1, 0, 0, 0), b.getEnd()); DCMIPeriod c = decodePeriod(DublinCoreValue.mk("start=2008-10-01")); assertEquals(createDate(2008, 10, 1, 0, 0, 0), c.getStart()); assertNull(c.getEnd()); DCMIPeriod d = decodePeriod(DublinCoreValue.mk("start=2008-10-01T10:20Z; end=2009-01-01; scheme=UNKNOWN")); assertNull(d); DCMIPeriod e = decodePeriod(DublinCoreValue.mk("start=2008-10-01T10:20Z; end=2009-01-01; scheme=W3C-DTF")); assertNotNull(e); DCMIPeriod f = decodePeriod(DublinCoreValue.mk("start=2008-10-01ERR; end=2009-01-01; scheme=W3C-DTF")); assertNull(f); }