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

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

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

import java.util.Locale;

import org.joda.time.DateTime;
import org.joda.time.Seconds;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import com.google.common.base.Optional;

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

    public static long getSecondsToWaitUntilStartTime(Optional startTime) {
        if (!startTime.isPresent()) {
            return 0L;
        }
        DateTime now = DateTime.now();
        long seconds = Seconds.secondsBetween(now, startTime.get()).getSeconds();
        if (seconds < 0L) {
            return 0L;
        }
        return seconds;
    }

    public static final DateTimeFormatter RFC1123_DATE_TIME_FORMATTER =
            DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss Z z")
            .withZoneUTC().withLocale(Locale.US);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy