ChronoZonedDateTime from() method in Java with Examples
The from() method of ChronoZonedDateTime interface in Java method obtains an instance of ChronoZonedDateTime from a temporal object.
Syntax:
static ChronoZonedDateTime
from(TemporalAccessor temporal)
Parameter: This method accepts a parameter temporal which specifies the temporal object to convert and not null.
Return Value: It returns the ChronoZonedDateTime and not null.
Exceptions: The function throws only DateTimeException which occurs if it is unable to convert it to a ChronoZonedDateTime.
Below programs illustrate the from() method of ChronoZonedDateTime in Java:
Note: The output will change on every run.
// Program to illustrate the from() method import java.util.*; import java.time.*; import java.time.chrono.*; public class GfG { public static void main(String[] args) { ChronoZonedDateTime dt = ZonedDateTime.from(ZonedDateTime.now()); System.out.println(dt); } } |
2019-05-26T12:36:04.419Z[Etc/UTC]
Recommended Posts:
- ChronoZonedDateTime get() method in Java with Examples
- ChronoZonedDateTime until() method in Java with Examples
- ChronoZonedDateTime withLaterOffsetAtOverlap() method in Java with Examples
- ChronoZonedDateTime isAfter() method in Java with Examples
- ChronoZonedDateTime withZoneSameInstant() method in Java with Examples
- ChronoZonedDateTime toString() method in Java with Examples
- ChronoZonedDateTime query() method in Java with Examples
- ChronoZonedDateTime getLong() method in Java with Examples
- ChronoZonedDateTime getOffset() method in Java with Examples
- ChronoZonedDateTime withEarlierOffsetAtOverlap() method in Java with Examples
- ChronoZonedDateTime withZoneSameLocal() method in Java with Examples
- ChronoZonedDateTime toEpochSecond() method in Java with Examples
- ChronoZonedDateTime compareTo() method in Java with Examples
- ChronoZonedDateTime equals() method in Java with Examples
- ChronoZonedDateTime format() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



