Example usage for java.time.temporal ChronoUnit DAYS

List of usage examples for java.time.temporal ChronoUnit DAYS

Introduction

In this page you can find the example usage for java.time.temporal ChronoUnit DAYS.

Prototype

ChronoUnit DAYS

To view the source code for java.time.temporal ChronoUnit DAYS.

Click Source Link

Document

Unit that represents the concept of a day.

Usage

From source file:Main.java

public static void main(String... args) {
    LocalDate today = LocalDate.now();
    LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS);
    LocalDate yesterday = tomorrow.minusDays(2);

    System.out.println(today);/*ww  w .j  a  v  a2 s .c o m*/
    System.out.println(tomorrow);
    System.out.println(yesterday);

}

From source file:Main.java

public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.now();
    ZonedDateTime n = dateTime.minus(12, ChronoUnit.DAYS);
    System.out.println(n);/*  w  ww  .j  av a 2s  .c o  m*/
}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    instant = instant.plus(100, ChronoUnit.DAYS);
    System.out.println(instant);/*from   ww  w  .  j ava  2 s.co m*/

}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    instant = instant.minus(100, ChronoUnit.DAYS);
    System.out.println(instant);/*from   w  ww  .  j a v a2 s. c o m*/

}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    instant = instant.truncatedTo(ChronoUnit.DAYS);
    System.out.println(instant);/*from  w w w.  j a  v  a 2  s. co  m*/

}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01);

    System.out.println(a.isSupported(ChronoUnit.DAYS));
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);

    LocalDateTime t = a.plus(10, ChronoUnit.DAYS);

    System.out.println(t);//from w w  w.  j  av  a  2s .  c  o m
}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    System.out.println(instant.isSupported(ChronoUnit.DAYS));

}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);

    long l = a.until(LocalDateTime.now(), ChronoUnit.DAYS);

    System.out.println(l);/*from  w  w w  .  ja va2 s  .c o  m*/
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime now = LocalDateTime.now();

    // Get the date time 10 days ago
    LocalDateTime localDateTime1 = now.minus(10, ChronoUnit.DAYS);
    System.out.println(localDateTime1);

}