Java ChronoUnit get hours between two LocalTime values

Description

Java ChronoUnit get hours between two LocalTime values


import java.time.LocalTime;
import java.time.temporal.ChronoUnit;

public class Main {
  public static void main(String[] args) {
    LocalTime lt1 = LocalTime.of(7, 0);
    LocalTime lt2 = LocalTime.of(9, 30);
    long hours = ChronoUnit.HOURS.between(lt1, lt2);
    System.out.println(hours);//  www .  j  a va2 s  .co  m
  }
}



PreviousNext

Related