List of usage examples for java.nio.file.attribute FileTime toString
@Override
public String toString()
From source file:Main.java
public static void main(String[] args) throws Exception { long time = System.currentTimeMillis(); FileTime fileTime = FileTime.fromMillis(time); System.out.println(fileTime.toString()); }
From source file:eu.edisonproject.classification.prepare.controller.DataPrepare.java
private LocalDate getCreationDate(File file) { Path p = Paths.get(file.getAbsolutePath()); BasicFileAttributes attr = null; try {//w w w.ja v a 2 s . co m attr = Files.readAttributes(p, BasicFileAttributes.class); } catch (IOException ex) { Logger.getLogger(Text2Avro.class.getName()).log(Level.SEVERE, null, ex); } FileTime ct = attr.creationTime(); DateTimeFormatter formatter; // // LocalDate.parse("2016-09-18T11:40:03.750522Z", formatter); formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'"); LocalDate date = null; try { date = LocalDate.parse(ct.toString(), formatter); } catch (java.lang.IllegalArgumentException ex) { formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'"); date = LocalDate.parse(ct.toString(), formatter); } Logger.getLogger(Text2Avro.class.getName()).log(Level.INFO, "CreationDate: {0}", date); return date; }
From source file:org.cryptomator.webdav.jackrabbit.AbstractEncryptedNode.java
@Override public void setProperty(DavProperty<?> property) throws DavException { getProperties().add(property);// www. ja va 2s .c o m LOG.info("Set property {}", property.getName()); try { final Path path = ResourcePathUtils.getPhysicalPath(this); if (DavPropertyName.CREATIONDATE.equals(property.getName()) && property.getValue() instanceof String) { final String createDateStr = (String) property.getValue(); final FileTime createTime = FileTimeUtils.fromRfc1123String(createDateStr); final BasicFileAttributeView attrView = Files.getFileAttributeView(path, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS); attrView.setTimes(null, null, createTime); LOG.info("Updating Creation Date: {}", createTime.toString()); } else if (DavPropertyName.GETLASTMODIFIED.equals(property.getName()) && property.getValue() instanceof String) { final String lastModifiedTimeStr = (String) property.getValue(); final FileTime lastModifiedTime = FileTimeUtils.fromRfc1123String(lastModifiedTimeStr); final BasicFileAttributeView attrView = Files.getFileAttributeView(path, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS); attrView.setTimes(lastModifiedTime, null, null); LOG.info("Updating Last Modified Date: {}", lastModifiedTime.toString()); } } catch (IOException e) { throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR); } }