net.sf.aguacate.util.time.TimeUtil Maven / Gradle / Ivy
package net.sf.aguacate.util.time;
import java.util.Calendar;
import java.util.Date;
public final class TimeUtil {
private TimeUtil() {
}
public static Date today() {
return today0().getTime();
}
public static Date today(int amount) {
Calendar calendar = today0();
calendar.add(Calendar.DAY_OF_YEAR, amount);
return calendar.getTime();
}
public static Date tomorrow() {
return today(1);
}
public static Date yesterday() {
return today(-1);
}
public static Date limit() {
return new Date(Long.MAX_VALUE);
}
static Calendar today0() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MILLISECOND, 999);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.HOUR, 23);
return calendar;
}
}