@Test public void testParseTimestamp() { final long time = new FTPMlsdListResponseReader().parseTimestamp("20130709111201"); assertEquals(1373368321000L, time); }
protected long parseTimestamp(final String timestamp) { if(null == timestamp) { return -1; } try { final Date parsed = new MDTMSecondsDateFormatter().parse(timestamp); return parsed.getTime(); } catch(InvalidDateException e) { log.warn("Failed to parse timestamp:" + e.getMessage()); try { final Date parsed = new MDTMMillisecondsDateFormatter().parse(timestamp); return parsed.getTime(); } catch(InvalidDateException f) { log.warn("Failed to parse timestamp:" + f.getMessage()); } } log.error(String.format("Failed to parse timestamp %s", timestamp)); return -1; }
FTPMlsdListResponseReader implements FTPDataResponseReader { protected long parseTimestamp(final String timestamp) { if(null == timestamp) { return -1; } try { final Date parsed = new MDTMSecondsDateFormatter().parse(timestamp); return parsed.getTime(); } catch(InvalidDateException e) { log.warn("Failed to parse timestamp:" + e.getMessage()); try { final Date parsed = new MDTMMillisecondsDateFormatter().parse(timestamp); return parsed.getTime(); } catch(InvalidDateException f) { log.warn("Failed to parse timestamp:" + f.getMessage()); } } log.error(String.format("Failed to parse timestamp %s", timestamp)); return -1; } }
FTPMlsdListResponseReader implements FTPDataResponseReader { protected long parseTimestamp(final String timestamp) { if(null == timestamp) { return -1; } try { final Date parsed = new MDTMSecondsDateFormatter().parse(timestamp); return parsed.getTime(); } catch(InvalidDateException e) { log.warn("Failed to parse timestamp:" + e.getMessage()); try { final Date parsed = new MDTMMillisecondsDateFormatter().parse(timestamp); return parsed.getTime(); } catch(InvalidDateException f) { log.warn("Failed to parse timestamp:" + f.getMessage()); } } log.error(String.format("Failed to parse timestamp %s", timestamp)); return -1; } FTPMlsdListResponseReader(); }
FTPMlsdListResponseReader implements FTPDataResponseReader { protected long parseTimestamp(final String timestamp) { if(null == timestamp) { return -1; } try { final Date parsed = new MDTMSecondsDateFormatter().parse(timestamp); return parsed.getTime(); } catch(InvalidDateException e) { log.warn("Failed to parse timestamp:" + e.getMessage()); try { final Date parsed = new MDTMMillisecondsDateFormatter().parse(timestamp); return parsed.getTime(); } catch(InvalidDateException f) { log.warn("Failed to parse timestamp:" + f.getMessage()); } } log.error(String.format("Failed to parse timestamp %s", timestamp)); return -1; } FTPMlsdListResponseReader(); @Override AttributedList<Path> read(final Path directory, final List<String> replies, final ListProgressListener listener); }
FTPMlsdListResponseReader implements FTPDataResponseReader { protected long parseTimestamp(final String timestamp) { if(null == timestamp) { return -1; } try { final Date parsed = new MDTMSecondsDateFormatter().parse(timestamp); return parsed.getTime(); } catch(InvalidDateException e) { log.warn("Failed to parse timestamp:" + e.getMessage()); try { final Date parsed = new MDTMMillisecondsDateFormatter().parse(timestamp); return parsed.getTime(); } catch(InvalidDateException f) { log.warn("Failed to parse timestamp:" + f.getMessage()); } } log.error(String.format("Failed to parse timestamp %s", timestamp)); return -1; } FTPMlsdListResponseReader(); @Override AttributedList<Path> read(final Path directory, final List<String> replies, final ListProgressListener listener);  }