Close

Java Date Time - OffsetDateTime.toInstant() Examples

Java Date Time Java Java API 


Class:

java.time.OffsetDateTime

java.lang.Objectjava.lang.Objectjava.time.OffsetDateTimejava.time.OffsetDateTimejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public Instant toInstant()
Converts this date-time to an Instant.

Examples


package com.logicbig.example.offsetdatetime;

import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;

public class ToInstantExample {

public static void main(String... args) {
OffsetDateTime d = OffsetDateTime.of(2016, 10, 15, 18,
20, 30, 100, ZoneOffset.ofHours(-5));
Instant instant = d.toInstant();
System.out.println(instant);
}
}

Output

2016-10-15T23:20:30.000000100Z




See Also