Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String getSegmentedStartUploadParams(String filePath) throws IOException {
- File file = new File(filePath);
- SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sssZZZZZ");
- Calendar cal = Calendar.getInstance();
- cal.set(1900, Calendar.JANUARY, 1);
- long lowerLimit = cal.getTimeInMillis();
- BasicFileAttributes attributes = Files.readAttributes(file.toPath(), BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
- String modifiedOn = dateFormatter.format(attributes.lastModifiedTime().toMillis());
- String createdOn = dateFormatter.format(attributes.creationTime().toMillis());
- int timeZoneOffset = TimeZone.getDefault().getRawOffset() / (1000 * 3600);
- return "{" +
- "\"name\":\"" + file.getName() + "\"," +
- "\"byteCount\":" + file.length() + "," +
- "\"createdOn\":\"" + createdOn + "\"," +
- "\"modifiedOn\":\"" + modifiedOn + "\", " +
- "\"timeZoneOffset\":" + timeZoneOffset +
- "}";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement