# LocalTime get() method in Java

Java 8Object Oriented ProgrammingProgramming

The value of the specified field from the LocalTime can be obtained using the get() method in the LocalTime class in Java. This method requires a single parameter i.e. ChronoField that is required and it returns the value of the specified field from the LocalTime.

A program that demonstrates this is given as follows

## Example

Live Demo

import java.time.*;
import java.time.temporal.ChronoField;
public class Main{
public static void main(String[] args){
LocalTime lt = LocalTime.parse("23:15:30");
System.out.println("The LocalTime is: " + lt);
System.out.println("The MINUTE_OF_HOUR is: " +
lt.get(ChronoField.MINUTE_OF_HOUR));
}
}

## output

The LocalTime is: 23:15:30
The MINUTE_OF_HOUR is: 15

Now let us understand the above program.

First the LocalTime object is displayed. Then the value of the ChronoField MINUTE_OF_HOUR from the LocalTime object is obtained using the get() method and printed. A code snippet that demonstrates this is as follows:

LocalTime lt = LocalTime.parse("23:15:30");

System.out.println("The LocalTime is: " + lt);
System.out.println("The MINUTE_OF_HOUR is: " +
lt.get(ChronoField.MINUTE_OF_HOUR));
Updated on 30-Jul-2019 22:30:25