OffsetDateTime toInstant() example
Description
OffsetDateTime toInstant()
converts this date-time to an Instant.
Syntax
toInstant
has the following syntax.
public Instant toInstant()
Example
The following example shows how to use toInstant
.
import java.time.Instant;
import java.time.OffsetDateTime;
//from w w w. j av a 2 s . co m
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.