OffsetDateTime toInstant()
converts this date-time to an Instant.
toInstant
has the following syntax.
public Instant toInstant()
The following example shows how to use toInstant
.
import java.time.Instant; import java.time.OffsetDateTime; /*from w w w .j av a 2s . com*/ public class Main { public static void main(String[] args) { OffsetDateTime o = OffsetDateTime.MAX; Instant i = o.toInstant(); System.out.println(i.getNano()); } }
The code above generates the following result.