All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.nagyesta.lowkeyvault.service.key.util.PeriodUtil Maven / Gradle / Ivy

There is a newer version: 2.5.81
Show newest version
package com.github.nagyesta.lowkeyvault.service.key.util;

import lombok.NonNull;

import java.time.OffsetDateTime;
import java.time.Period;
import java.time.temporal.ChronoUnit;

public final class PeriodUtil {

    private PeriodUtil() {
        throw new IllegalCallerException("Utility cannot be instantiated.");
    }

    public static long asDays(@NonNull final Period period) {
        return asDays(period, OffsetDateTime.now());
    }

    static long asDays(final Period period, final OffsetDateTime relativeTo) {
        return ChronoUnit.DAYS.between(relativeTo, relativeTo.plus(period));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy