@Test public void testDecodeDate() { assertEquals(createDate(2008, 10, 1, 0, 0, 0), decodeDate(DublinCoreValue.mk("2008-10-01"))); assertEquals(createDate(1999, 3, 21, 14, 30, 0, "UTC"), decodeDate(DublinCoreValue.mk("1999-03-21T14:30Z"))); assertEquals(createDate(1999, 3, 21, 14, 30, 0, "UTC"), decodeDate(DublinCoreValue.mk("1999-03-21T14:30:00Z"))); assertEquals(createDate(1999, 3, 21, 14, 30, 15, "UTC"), decodeDate(DublinCoreValue.mk("1999-03-21T14:30:15Z"))); assertEquals(createDate(2001, 9, 11, 0, 0, 0), decodeDate(DublinCoreValue.mk("2001-09-11"))); assertEquals(createDate(2011, 2, 24, 7, 0, 0, "UTC"), decodeDate(DublinCoreValue.mk("1298530800000"))); assertEquals(createDate(2011, 2, 24, 7, 0, 0, "UTC"), decodeDate("1298530800000")); logger.info(decodeDate(DublinCoreValue.mk("2009-03-31")).toString()); logger.info(decodeDate(DublinCoreValue.mk("2009-09-11")).toString()); logger.info(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(decodeDate(DublinCoreValue.mk( "2009-03-31")))); }
public static Date decodeDate(DublinCoreValue value) { if (!value.hasEncodingScheme() || value.getEncodingScheme().get().equals(DublinCore.ENC_SCHEME_W3CDTF)) { try { return parseW3CDTF(value.getValue()); } catch (IllegalArgumentException ignore) { } } try { long timestamp = Long.parseLong(value.getValue()); Date decoded = new java.util.Date(timestamp); return decoded; } catch (NumberFormatException nfe) { } return null; }
EncodingSchemeUtils { public static Date decodeDate(DublinCoreValue value) { if (!value.hasEncodingScheme() || value.getEncodingScheme().get().equals(DublinCore.ENC_SCHEME_W3CDTF)) { try { return parseW3CDTF(value.getValue()); } catch (IllegalArgumentException ignore) { } } try { long timestamp = Long.parseLong(value.getValue()); Date decoded = new java.util.Date(timestamp); return decoded; } catch (NumberFormatException nfe) { } return null; } }
EncodingSchemeUtils { public static Date decodeDate(DublinCoreValue value) { if (!value.hasEncodingScheme() || value.getEncodingScheme().get().equals(DublinCore.ENC_SCHEME_W3CDTF)) { try { return parseW3CDTF(value.getValue()); } catch (IllegalArgumentException ignore) { } } try { long timestamp = Long.parseLong(value.getValue()); Date decoded = new java.util.Date(timestamp); return decoded; } catch (NumberFormatException nfe) { } return null; } private  EncodingSchemeUtils(); }
EncodingSchemeUtils { public static Date decodeDate(DublinCoreValue value) { if (!value.hasEncodingScheme() || value.getEncodingScheme().get().equals(DublinCore.ENC_SCHEME_W3CDTF)) { try { return parseW3CDTF(value.getValue()); } catch (IllegalArgumentException ignore) { } } try { long timestamp = Long.parseLong(value.getValue()); Date decoded = new java.util.Date(timestamp); return decoded; } catch (NumberFormatException nfe) { } return null; } 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); }
EncodingSchemeUtils { public static Date decodeDate(DublinCoreValue value) { if (!value.hasEncodingScheme() || value.getEncodingScheme().get().equals(DublinCore.ENC_SCHEME_W3CDTF)) { try { return parseW3CDTF(value.getValue()); } catch (IllegalArgumentException ignore) { } } try { long timestamp = Long.parseLong(value.getValue()); Date decoded = new java.util.Date(timestamp); return decoded; } catch (NumberFormatException nfe) { } return null; } 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);  }