Close

Java Date Time - LocalTime.getHour() Examples

Java Date Time Java Java API 


Class:

java.time.LocalTime

java.lang.Objectjava.lang.Objectjava.time.LocalTimejava.time.LocalTimejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public int getHour()

This method returns the hour-of-day field from this LocalTime instance.



Examples


package com.logicbig.example.localtime;

import java.time.LocalTime;

public class GetHourExample {
public static void main (String... args) {
LocalTime d = LocalTime.of(14, 30, 40, 3000);
int hour = d.getHour();
System.out.println(hour);
}
}

Output

14




See Also