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

net.alloyggp.tournament.impl.TimeUtils Maven / Gradle / Ivy

There is a newer version: 0.1.0
Show newest version
package net.alloyggp.tournament.impl;

import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Optional;

public class TimeUtils {
    private TimeUtils() {
        //Not instantiable
    }

    public static long getSecondsToWaitUntilStartTime(Optional startTime) {
        if (!startTime.isPresent()) {
            return 0L;
        }
        LocalDateTime now = LocalDateTime.now();
        long seconds = now.until(startTime.get(), ChronoUnit.SECONDS);
        if (seconds < 0L) {
            return 0L;
        }
        return seconds;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy