Example usage for java.time Duration ofDays

List of usage examples for java.time Duration ofDays

Introduction

In this page you can find the example usage for java.time Duration ofDays.

Prototype

public static Duration ofDays(long days) 

Source Link

Document

Obtains a Duration representing a number of standard 24 hour days.

Usage

From source file:Main.java

public static void main(String[] args) {
    Duration duration = Duration.ofDays(10);
    System.out.println(duration);
}

From source file:Main.java

public static void main(String[] args) {

    Duration d1 = Duration.ofDays(2);
    System.out.println(d1);/*from  w  ww  . j a v a  2s . c  om*/

    Duration d2 = Duration.ofMinutes(2);
    System.out.println(d2);

}

From source file:Main.java

public static void main(String[] args) {
    Duration duration = Duration.ofDays(33); //seconds or nanos

    Duration duration1 = Duration.ofHours(33); //seconds or nanos
    Duration duration2 = Duration.ofMillis(33); //seconds or nanos
    Duration duration3 = Duration.ofMinutes(33); //seconds or nanos
    Duration duration4 = Duration.ofNanos(33); //seconds or nanos
    Duration duration5 = Duration.ofSeconds(33); //seconds or nanos
    Duration duration6 = Duration.between(LocalDate.of(2012, 11, 11), LocalDate.of(2013, 1, 1));

    System.out.println(duration6.getSeconds());
    System.out.println(duration.getNano());
    System.out.println(duration.getSeconds());
}

From source file:Main.java

public static void main(String[] args) {
    Duration duration = Duration.ofDays(2);
    Temporal l = duration.subtractFrom(LocalDateTime.now());

    System.out.println(l);/*from w ww  .  j a  va2s  .  co  m*/
}

From source file:Main.java

public static void main(String[] args) {
    Duration duration = Duration.ofDays(2);
    Temporal l = duration.addTo(LocalDateTime.now());

    System.out.println(l);//from   w w  w. j  a v a 2 s .  c om

}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    instant = instant.plus(Duration.ofDays(100));
    System.out.println(instant);/*  w  ww  .jav  a2  s .  c om*/

}

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    instant = instant.minus(Duration.ofDays(100));
    System.out.println(instant);/* www  .j  a  v  a 2s. c om*/

}

From source file:Main.java

public static void main(String[] args) {
    LocalTime localTime = LocalTime.of(11, 20, 50);
    System.out.println(localTime.plus(3, ChronoUnit.HOURS));
    System.out.println(localTime.plus(Duration.ofDays(3))); //11:20:50
    try {//from  www  . ja  v  a  2 s. co m
        System.out.println(localTime.plus(Period.ofDays(3)));
    } catch (UnsupportedTemporalTypeException e) {
        e.printStackTrace();
    }

}

From source file:Main.java

public static void main(String[] args) {

    ZonedDateTime _130AMChicagoTime = ZonedDateTime.of(2014, 3, 9, 1, 30, 0, 0, ZoneId.of("America/Chicago"));

    System.out.println(_130AMChicagoTime.plusHours(3));
    System.out.println(_130AMChicagoTime.plus(Duration.ofHours(3)));

    System.out.println(_130AMChicagoTime.plus(Duration.ofDays(2)));
    System.out.println(_130AMChicagoTime.plus(Period.ofDays(2)));
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2012, 11, 23);
    System.out.println(localDate.plus(3, ChronoUnit.DAYS)); //2012-11-26

    System.out.println(localDate.plus(Period.ofDays(3))); //2012-11-26
    try {//ww w  .j  av a2 s .c  o m
        System.out.println(localDate.plus(Duration.ofDays(3)));

        System.out.println(localDate.plus(4, ChronoUnit.FOREVER));
    } catch (UnsupportedTemporalTypeException e) {
        e.printStackTrace();
    }
}