Example usage for java.time ZonedDateTime withYear

List of usage examples for java.time ZonedDateTime withYear

Introduction

In this page you can find the example usage for java.time ZonedDateTime withYear.

Prototype

public ZonedDateTime withYear(int year) 

Source Link

Document

Returns a copy of this ZonedDateTime with the year altered.

Usage

From source file:Main.java

public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.now();
    dateTime = dateTime.withYear(2000);
    System.out.println(dateTime);
}

From source file:sorcer.file.ScratchDirManager.java

private boolean isCutoffTime(Path path, long cutOffTime) throws IOException {
    ZonedDateTime now = ZonedDateTime.now();
    BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
    ZonedDateTime created = ZonedDateTime.ofInstant(attrs.creationTime().toInstant(), now.getZone());

    created = created.withYear(now.getYear()).withMonth(now.getMonthValue());

    ZonedDateTime cutoff = created.plus(cutOffTime, MILLIS);

    log.info("Created {}", created);
    log.info("now     {}", now);
    log.info("cutoff  {}", cutoff);

    return now.isAfter(cutoff);
}