Advertisement
Guest User

Untitled

a guest
May 28th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. private String getSegmentedStartUploadParams(String filePath) throws IOException {
  2.         File file = new File(filePath);
  3.         SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sssZZZZZ");
  4.         Calendar cal = Calendar.getInstance();
  5.         cal.set(1900, Calendar.JANUARY, 1);
  6.         long lowerLimit = cal.getTimeInMillis();
  7.         BasicFileAttributes attributes = Files.readAttributes(file.toPath(), BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
  8.         String modifiedOn = dateFormatter.format(attributes.lastModifiedTime().toMillis());
  9.         String createdOn = dateFormatter.format(attributes.creationTime().toMillis());
  10.  
  11.         int timeZoneOffset = TimeZone.getDefault().getRawOffset() / (1000 * 3600);
  12.         return "{" +
  13.                 "\"name\":\"" + file.getName() + "\"," +
  14.                 "\"byteCount\":" + file.length() + "," +
  15.                 "\"createdOn\":\"" + createdOn + "\"," +
  16.                 "\"modifiedOn\":\"" + modifiedOn + "\", " +
  17.                 "\"timeZoneOffset\":" + timeZoneOffset +
  18.                 "}";
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement