Here you can find the source of toInstant(Date date)
public static Instant toInstant(Date date)
//package com.java2s; //License from project: Open Source License import java.time.Instant; import java.util.Date; public class Main { public static final Instant INF_FUTURE = Instant.MAX; public static final Instant INF_PAST = Instant.MIN; public static Instant toInstant(Date date) { if (isInfFuture(date)) { return INF_FUTURE; } else if (isInfPast(date)) { return INF_PAST; } else {//w w w .j a v a 2 s .com return date.toInstant(); } } public static boolean isInfFuture(Instant instant) { return INF_FUTURE.equals(instant); } public static boolean isInfFuture(Date date) { return date.getYear() > 8000; // Hacky, but needs to match Ruby's Time::INF_FUTURE } public static boolean isInfPast(Instant instant) { return INF_PAST.equals(instant); } public static boolean isInfPast(Date date) { return date.getYear() < -10000; } }