how to get time now hours 2c minutes 2c seconds each one separately

Solutions on MaxInterview for how to get time now hours 2c minutes 2c seconds each one separately by the best coders in the world

showing results for - "how to get time now hours 2c minutes 2c seconds each one separately"
Sophia
12 Jan 2020
1package com.zetcode;
2
3import java.time.LocalTime;
4
5public class JavaLocalTimeParts {
6
7    public static void main(String[] args) {
8
9        LocalTime time = LocalTime.now();
10
11        System.out.printf("Hour: %s%n", time.getHour());
12        System.out.printf("Minute: %s%n", time.getMinute());
13        System.out.printf("Second: %s%n", time.getSecond());
14    }
15}
16
17	//The getHour() gets the hour part, the getMinute() gets the minute part, and the getSecond() the second part of the LocalTime.
18	
19	//This is the output.
20	//Hour: 18
21	//Minute: 25
22	//Second: 55
23
24
similar questions