Example usage for java.time.temporal ChronoUnit HOURS

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

Introduction

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

Prototype

ChronoUnit HOURS

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

Click Source Link

Document

Unit that represents the concept of an hour.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalTime s = l.truncatedTo(ChronoUnit.HOURS);
    System.out.println(s);//from w  w w.  j a v  a2s. c  o m
}

From source file:Main.java

public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    boolean z = m.isSupported(ChronoUnit.HOURS);
    System.out.println(z);/*from  w w w .  ja va 2  s. c o  m*/

}

From source file:Main.java

public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    long s = l.until(LocalTime.NOON, ChronoUnit.HOURS);
    System.out.println(s);/*  w  w  w.ja v a  2 s. c  o m*/
}

From source file:Main.java

public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    OffsetDateTime d = o.plus(20, ChronoUnit.HOURS);
    System.out.println(d);//from  w ww. j a v a 2s.c o m
}

From source file:Main.java

public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    OffsetDateTime d = o.minus(20, ChronoUnit.HOURS);
    System.out.println(d);//from  ww w  .j a  v  a2s. com
}

From source file:Main.java

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

    LocalDateTime t = a.truncatedTo(ChronoUnit.HOURS);

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

From source file:Main.java

public static void main(String[] args) {
    Instant t1 = Instant.now();
    long hours = 2;
    long minutes = 30;
    Instant t2 = t1.plus(hours, ChronoUnit.HOURS).plus(minutes, ChronoUnit.MINUTES);

    System.out.println(String.format("now %s and later %s", t1, t2));
}

From source file:Main.java

public static void main(String[] args) {
    Instant timestamp = Instant.now();
    System.out.println(timestamp);
    System.out.println(timestamp.plus(1, ChronoUnit.HOURS));

}

From source file:Main.java

public static void main(String[] args) {
    Instant t1 = Instant.now();
    long hours = 2;
    long minutes = 30;
    Instant t2 = t1.plus(hours, ChronoUnit.HOURS).plus(minutes, ChronoUnit.MINUTES);

    long minutesBetween = Duration.between(t1, t2).toMinutes();
    System.out.println(minutesBetween);
}

From source file:Main.java

public static void main(String[] args) {
    Instant t1 = Instant.now();
    long hours = 2;
    long minutes = 30;
    Instant t2 = t1.plus(hours, ChronoUnit.HOURS).plus(minutes, ChronoUnit.MINUTES);

    Duration gap = Duration.ofSeconds(13);
    Instant later = t1.plus(gap);
    System.out.println(later);// w w  w  . jav a  2s. c  o  m

    System.out.println(ChronoUnit.MILLIS.between(t1, t2));
}