![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 from() method in Java
An instance of a LocalTime object can be obtained from a Temporal object using the from() method in the LocalTime class in Java. This method requires a single parameter i.e. the Temporal object and it returns the LocalTime object that is obtained from the Temporal object.
A program that demonstrates this is given as follows:
import java.time.*; public class Main { public static void main(String[] args) { LocalTime lt = LocalTime.from(ZonedDateTime.now()); System.out.println("The LocalTime is: " + lt); } }
The output of the above program is as follows:
The LocalTime is: 10:09:29.696
Now let us understand the above program.
The instance of the LocalTime object is obtained from the Temporal object using the from() method and then it is displayed. A code snippet that demonstrates this is as follows:
LocalTime lt = LocalTime.from(ZonedDateTime.now()); System.out.println("The LocalTime is: " + lt);
Advertisements