Here you can find the source of plus(Instant instant, Duration add)
public static Instant plus(Instant instant, Duration add)
//package com.java2s; //License from project: Open Source License import java.time.Duration; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.Date; public class Main { public static final Duration INF_POSITIVE = ChronoUnit.FOREVER.getDuration(); public static final Duration INF_NEGATIVE = INF_POSITIVE.negated(); public static final Instant INF_FUTURE = Instant.MAX; public static final Instant INF_PAST = Instant.MIN; public static Instant plus(Instant instant, Duration add) { if (isInfFuture(instant)) { return INF_FUTURE; } else if (isInfPast(instant)) { return INF_PAST; } else if (isInfPositive(add)) { return INF_FUTURE; } else if (isInfNegative(add)) { return INF_PAST; } else {/* w ww . jav a2s. c o m*/ return instant.plus(add); } } 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; } public static boolean isInfPositive(Duration duration) { return INF_POSITIVE.equals(duration); } public static boolean isInfNegative(Duration duration) { return INF_NEGATIVE.equals(duration); } }