package jetbrains.buildServer.serverSide; import org.jetbrains.annotations.NotNull; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; /** * @author Eugene Petrenko * Created: 31.03.2010 16:16:08 */ public class TimeFactory { private final ThreadLocal myDateFormat = new ThreadLocal() { @Override protected DateFormat initialValue() { return new SimpleDateFormat("HH:mm:ss"); } }; @NotNull public Date getTime() { return (new Date()); } @NotNull public Date getTimeBefore(int minutes, int seconds) { return (new Date(new Date().getTime() - 1000L * 60L * minutes - 1000L * seconds)); } public String format(Date date) { return myDateFormat.get().format(date); } }