Java LocalTime create from 'of' factory method as of(7, 30, 50)

Description

Java LocalTime create from 'of' factory method as of(7, 30, 50)

import java.time.LocalTime;

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

    // 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);//from  ww  w.  jav a  2s  . c  om
    System.out.println(lt2);
    System.out.println(lt3);
    System.out.println(lt4);
  }
}



PreviousNext

Related