The atZone(ZoneId zone) method of ChronoLocalDateTime interface is used to combine this ChronoLocalDateTime with a time-zone whose ZoneId is given as parameter to create an ZonedDateTime object. This method takes ZoneId as a parameter and combines the time-zone with this ChronoLocalDateTime after operation returns a ChronoZonedDateTime object.
ChronoZonedDateTime<D> atZone(ZoneId zone)
Parameters: This method accepts one parameter zone which is the zone to combine to this ChronoLocalDateTime object. It should not be null.
Return Value: This method returns a ChronoZonedDateTime which is the combination of current zone of ChronoLocalDateTime and the zone passed as the parameter.
Below programs illustrate the ChronoLocalDateTime.atZone() method:
ChronoLocalDateTime: 2018-12-06T19:21:12 ChronoZonedDateTime: 2018-12-06T19:21:12+01:00[Europe/Paris]
ChronoLocalDateTime: 2018-12-06T19:21:12 ChronoZonedDateTime: 2018-12-06T19:21:12+03:00[Asia/Aden]
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.