Java – Update last modified date of a file
In Java, we can use the NIO Files.setLastModifiedTime(path, FileTime) to update the last modified date or time of a file. Path path = Paths.get("/path/file"); LocalDate newLocalDate = LocalDate.of(1997, 12, 31); // year, month, dayOfMonth, hour, minute, second LocalDateTime newLocalDateTime = LocalDateTime.of(1999, 9, 30, 10, 30, 22); // convert LocalDateTime to Instant Instant instant = newLocalDateTime.toInstant(ZoneOffset.UTC); …