Java Date Time Java Java API
java.time.ZonedDateTime
public OffsetDateTime toOffsetDateTime()
Returns a corresponding instance of OffsetDateTime.
package com.logicbig.example.zoneddatetime;import java.time.OffsetDateTime;import java.time.ZonedDateTime;public class ToOffsetDateTimeExample { public static void main(String... args) { ZonedDateTime d = ZonedDateTime.now(); System.out.println(d); OffsetDateTime offsetDateTime = d.toOffsetDateTime(); System.out.println(offsetDateTime); }}
2017-05-01T16:00:30.495-05:00[America/Chicago]2017-05-01T16:00:30.495-05:00