

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
LocalTime ofSecondOfDay() method in Java
A LocalTime object can be obtained using the seconds of the day with the ofSecondOfDay() method in the LocalTime class in Java. This method requires a single parameter i.e. the seconds of the day and it returns the LocalTime object for the seconds of the day.
A program that demonstrates this is given as follows
Example
import java.time.*; public class Demo { public static void main(String[] args) { long seconds = 18930; System.out.println("The seconds of the day: " + seconds); System.out.println("The LocalTime is: " + LocalTime.ofSecondOfDay(seconds)); } }
output
The seconds of the day: 18930 The LocalTime is: 05:15:30
Now let us understand the above program.
First the seconds of the day are displayed. Then the LocalTime object is obtained using the seconds of the day with the ofSecondOfDay() method and printed. A code snippet that demonstrates this is as follows:
long seconds = 18930; System.out.println("The seconds of the day: " + seconds); System.out.println("The LocalTime is: " + LocalTime.ofSecondOfDay(seconds));
- Related Questions & Answers
- LocalTime minusNanos() method in Java
- LocalTime minusMinutes() method in Java
- LocalTime minusHours() method in Java
- LocalTime compareTo() method in Java
- LocalTime ofNanoOfDay() method in Java
- LocalTime getMinute() method in Java
- LocalTime get() method in Java
- LocalTime isAfter() method in Java
- LocalTime isBefore() method in Java
- LocalTime getHour() method in Java
- LocalTime getNano() method in Java
- LocalTime getSecond() method in Java
- LocalTime hashCode() method in Java
- LocalTime equals() method in Java
- LocalTime format() method in Java
Advertisements