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

com.github.twitch4j.common.util.TimeUtils Maven / Gradle / Ivy

package com.github.twitch4j.common.util;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class TimeUtils {

    /**
     * Gets the current time in millis
     *
     * @return long
     */
    public static long getCurrentTimeInMillis() {
        return Calendar.getInstance().getTimeInMillis();
    }

    /**
     * @param time an {@link Instant}
     * @return a {@link Calendar} instance for the instant, in the system default zone
     */
    public static Calendar fromInstant(Instant time) {
        return GregorianCalendar.from(ZonedDateTime.ofInstant(time, ZoneId.systemDefault()));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy