更新工具

This commit is contained in:
坏黑 2018-04-10 22:34:37 +08:00
parent 33905330f3
commit 4e7fc42167

View File

@ -0,0 +1,31 @@
package me.skymc.taboolib.timeutil;
import java.util.concurrent.TimeUnit;
import lombok.Data;
/**
* @author sky
* @since 2018-04-10 22:11:04
*/
@Data
public class TimeFormatter {
private long days;
private long hours;
private long minutes;
private long seconds;
private long milliseconds;
public TimeFormatter(long millisecond) {
days = TimeUnit.MILLISECONDS.toDays(millisecond);
hours = TimeUnit.MILLISECONDS.toHours(millisecond) - days * 24L;
minutes = TimeUnit.MILLISECONDS.toMinutes(millisecond) - TimeUnit.MILLISECONDS.toHours(millisecond) * 60L;
seconds = TimeUnit.MILLISECONDS.toSeconds(millisecond) - TimeUnit.MILLISECONDS.toMinutes(millisecond) * 60L;
milliseconds = TimeUnit.MILLISECONDS.toMillis(millisecond) - TimeUnit.MILLISECONDS.toSeconds(millisecond) * 1000L;
}
public long toMilliseconds() {
return milliseconds + (seconds * 1000L) + (minutes * 1000L * 60L) + (hours * 1000L * 60L * 60L) + (days * 1000L * 60L * 60L * 24L);
}
}