Java LocalTime 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(6, 0); LocalTime lt2 = LocalTime.of(9, 30); /* w w w. j a v a2s. c om*/ long hours = ChronoUnit.HOURS.between(lt1, lt2); System.out.println(hours); } }