@Test public void testGetTimeStampFromFile() throws Exception { URL url = UrlFactory.getUrl("sftp.3gpp: URLConnection conn = url.openConnection(); Assert.assertTrue(conn instanceof Sftp3gppUrlConnection); Sftp3gppUrlConnection c = (Sftp3gppUrlConnection) conn; Assert.assertTrue(Boolean.parseBoolean(c.getQueryMap().get("deletefile"))); long t1 = c.getTimeStampFromFile("A20111102.1300-0500-1305-0500_MME00001"); long t2 = c.getTimeStampFromFile("A20111102.1305-0500-1310-0500_MME00001"); Assert.assertTrue(t2 > t1); Assert.assertTrue(t2 - t1 == Long.parseLong(c.getQueryMap().get("step")) * 1000); }
public long getTimeStampFromFile(String fileName) { Pattern p = Pattern.compile("\\w(\\d+)\\.(\\d+)-(\\d+)-(\\d+)-(\\d+)_.+"); Matcher m = p.matcher(fileName); if (m.find()) { String value = m.group(1) + '-' + m.group(4); try { DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd-HHmm"); DateTime dateTime = dtf.parseDateTime(value); return dateTime.getMillis(); } catch (Exception e) { log().warn("getTimeStampFromFile: malformed 3GPP file " + fileName + ", because " + e.getMessage()); return 0; } } return 0; }
Sftp3gppUrlConnection extends SftpUrlConnection { public long getTimeStampFromFile(String fileName) { Pattern p = Pattern.compile("\\w(\\d+)\\.(\\d+)-(\\d+)-(\\d+)-(\\d+)_.+"); Matcher m = p.matcher(fileName); if (m.find()) { String value = m.group(1) + '-' + m.group(4); try { DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd-HHmm"); DateTime dateTime = dtf.parseDateTime(value); return dateTime.getMillis(); } catch (Exception e) { log().warn("getTimeStampFromFile: malformed 3GPP file " + fileName + ", because " + e.getMessage()); return 0; } } return 0; } }
Sftp3gppUrlConnection extends SftpUrlConnection { public long getTimeStampFromFile(String fileName) { Pattern p = Pattern.compile("\\w(\\d+)\\.(\\d+)-(\\d+)-(\\d+)-(\\d+)_.+"); Matcher m = p.matcher(fileName); if (m.find()) { String value = m.group(1) + '-' + m.group(4); try { DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd-HHmm"); DateTime dateTime = dtf.parseDateTime(value); return dateTime.getMillis(); } catch (Exception e) { log().warn("getTimeStampFromFile: malformed 3GPP file " + fileName + ", because " + e.getMessage()); return 0; } } return 0; } protected  Sftp3gppUrlConnection(URL url); }
Sftp3gppUrlConnection extends SftpUrlConnection { public long getTimeStampFromFile(String fileName) { Pattern p = Pattern.compile("\\w(\\d+)\\.(\\d+)-(\\d+)-(\\d+)-(\\d+)_.+"); Matcher m = p.matcher(fileName); if (m.find()) { String value = m.group(1) + '-' + m.group(4); try { DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd-HHmm"); DateTime dateTime = dtf.parseDateTime(value); return dateTime.getMillis(); } catch (Exception e) { log().warn("getTimeStampFromFile: malformed 3GPP file " + fileName + ", because " + e.getMessage()); return 0; } } return 0; } protected  Sftp3gppUrlConnection(URL url); String get3gppFileName(); long getTimeStampFromFile(String fileName); Map<String,String> getQueryMap(); @SuppressWarnings("unchecked") List<String> getFileList(); void deleteFile(String fileName); InputStream getFile(String fileName); }
Sftp3gppUrlConnection extends SftpUrlConnection { public long getTimeStampFromFile(String fileName) { Pattern p = Pattern.compile("\\w(\\d+)\\.(\\d+)-(\\d+)-(\\d+)-(\\d+)_.+"); Matcher m = p.matcher(fileName); if (m.find()) { String value = m.group(1) + '-' + m.group(4); try { DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd-HHmm"); DateTime dateTime = dtf.parseDateTime(value); return dateTime.getMillis(); } catch (Exception e) { log().warn("getTimeStampFromFile: malformed 3GPP file " + fileName + ", because " + e.getMessage()); return 0; } } return 0; } protected  Sftp3gppUrlConnection(URL url); String get3gppFileName(); long getTimeStampFromFile(String fileName); Map<String,String> getQueryMap(); @SuppressWarnings("unchecked") List<String> getFileList(); void deleteFile(String fileName); InputStream getFile(String fileName);  }