This static method returns the ZonedDateTime instance based on the provided TemporalAccessor.
The provided temporal accessor must have all fields needed for the OffsetDateTime instance creation otherwise DateTimeException will be thrown.
  

package com.logicbig.example.zoneddatetime;
import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
public class FromExample {
    public static void main(String... args) {
        OffsetDateTime date = OffsetDateTime.now();
        System.out.println(date);
        ZonedDateTime zdt = ZonedDateTime.from(date);
        System.out.println(zdt);
    }
}
Output
2025-10-29T18:15:32.933+08:00
2025-10-29T18:15:32.933+08:00
  

package com.logicbig.example.zoneddatetime;
import java.time.ZonedDateTime;
public class FromExample2 {
    public static void main(String... args) {
        ZonedDateTime date = ZonedDateTime.now();
        System.out.println(date);
        ZonedDateTime zdt = ZonedDateTime.from(date);
        System.out.println(zdt);
    }
}
Output
2025-10-29T18:15:36.025+08:00[America/Chicago]
2025-10-29T18:15:36.025+08:00[America/Chicago]
  

package com.logicbig.example.zoneddatetime;
import java.time.OffsetTime;
import java.time.ZonedDateTime;
public class FromExample3 {
    public static void main(String... args) {
        OffsetTime date = OffsetTime.now();
        System.out.println(date);
        ZonedDateTime zdt = ZonedDateTime.from(date);
        System.out.println(zdt);
    }
}
Output
java.time.DateTimeException: Unable to obtain ZonedDateTime from TemporalAccessor: 18:15:43.977+08:00 of type java.time.OffsetTime
    at java.time.ZonedDateTime.from (ZonedDateTime.java:565)
    at com.logicbig.example.zoneddatetime.FromExample3.main (FromExample3.java:17)
Caused by: java.time.DateTimeException: Unable to obtain LocalDate from TemporalAccessor: 18:15:43.977+08:00 of type java.time.OffsetTime
    at java.time.LocalDate.from (LocalDate.java:368)
    at java.time.ZonedDateTime.from (ZonedDateTime.java:559)
    at com.logicbig.example.zoneddatetime.FromExample3.main (FromExample3.java:17)