Java Utililty Methods Instant Calculate

List of utility methods to do Instant Calculate

Description

The list of methods to do Instant Calculate are organized into topic(s).

Method

Instantplus(Instant instant, Duration add)
plus
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;
...
InstantplusMilli(Instant _date, long _milli)
Add _milli milliseconds to _date
return _date.plus(_milli, ChronoField.MILLI_OF_DAY.getBaseUnit());
InstantrestrictToDaytime(Instant instantToRestrict, Instant thresholdTime, ZoneId userZoneId)
restrict To Daytime
ZonedDateTime zonedDateTime = instantToRestrict.atZone(userZoneId);
if (zonedDateTime.getHour() <= earliestHourForAutomatedMessage) {
    zonedDateTime = ZonedDateTime.of(zonedDateTime.toLocalDate(), earliestHour, userZoneId);
    return thresholdTime == null || zonedDateTime.toInstant().isBefore(thresholdTime)
            ? zonedDateTime.toInstant()
            : thresholdTime;
} else if (zonedDateTime.getHour() >= latestHourForAutomatedMessages) {
    zonedDateTime = ZonedDateTime.of(zonedDateTime.toLocalDate(), latestHour, userZoneId);
...
InstantroundUp(final Instant time, final Duration duration)
Round time to next multiple of given duration
return roundUp(time, duration.getSeconds());
longsecondsAgo(Instant end)
seconds Ago
return Duration.between(Instant.EPOCH, end).getSeconds();