Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.time.LocalTime;

public class Main {

    public static void main(String[] args) {
        LocalTime currentTime = LocalTime.now(); // current time
        System.out.println(currentTime);

        LocalTime midday = LocalTime.of(12, 0); // 12:00
        System.out.println(midday); // 12:00

        LocalTime afterMidday = LocalTime.of(13, 30, 15); // 13:30:15
        System.out.println(afterMidday); // 13:30:15

        // 12345th second of day (03:25:45)
        LocalTime fromSecondsOfDay = LocalTime.ofSecondOfDay(12345);
        System.out.println(fromSecondsOfDay); // 03:25:45
    }
}