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

net.sf.aguacate.util.time.TimeUtil Maven / Gradle / Ivy

There is a newer version: 0.10.9
Show newest version
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;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy