Java - Date Time Local Time


LocalTime class represents a time without a date or time zone.

Time is represented to a nanosecond precision.

LocalTime contains MIN, MAX, MIDNIGHT, and NOON constants that represent time constants of 00:00,23:59:59.999999999, 00:00, and 12:00, respectively.

Methods in this class let you create, manipulate, and compare times in different ways.

The following snippet of code creates some LocalTime objects:


import java.time.LocalTime;

public class Main {
  public static void main(String[] args) {
    // Get the current local time
    LocalTime lt1 =;

    // Create a local time 07:30
    LocalTime lt2 = LocalTime.of(7, 30);

    // Create a local time 07:30:50
    LocalTime lt3 = LocalTime.of(7, 30, 50);

    // Create a local time 07:30:50.000005678
    LocalTime lt4 = LocalTime.of(7, 30, 50, 5678);
    System.out.println(lt1);// w w w .  ja  v a 2 s  .c om