Here you can find the source of secondsLater(Integer seconds)
Parameter | Description |
---|---|
seconds | number of seconds |
public static Date secondsLater(Integer seconds)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**/*from w w w .j a v a2 s. c om*/ * Get date for number of seconds later * * @param seconds number of seconds * @return date */ public static Date secondsLater(Integer seconds) { return forCalendarDiff(Calendar.SECOND, seconds); } /** * Get date for calendar difference from current date * * @param field difference field (Calendar.DATE, Calendar.MINUTE ... etc) * @param amount how much? * @return date for the difference */ public static Date forCalendarDiff(int field, int amount) { GregorianCalendar gCal = new GregorianCalendar(); gCal.add(field, amount); return new Date(gCal.getTimeInMillis()); } }