List of usage examples for java.util Calendar add
public abstract void add(int field, int amount);
From source file:Main.java
public static Date getFetchDelayDate(Integer dateDelayMinutes) { Calendar c = Calendar.getInstance(); if (dateDelayMinutes > 0) { dateDelayMinutes = -dateDelayMinutes; }/*from ww w .j av a 2 s . c o m*/ c.add(Calendar.MINUTE, dateDelayMinutes); return c.getTime(); }
From source file:Main.java
public static Date getNearestFutureDateWithHour(int hourOfDay) { Calendar cal = Calendar.getInstance(); int hourOfDayNow = cal.get(Calendar.HOUR_OF_DAY); if (hourOfDayNow > hourOfDay) { cal.add(Calendar.DAY_OF_MONTH, 1); }//from w w w . jav a2 s. c o m cal.set(Calendar.HOUR, hourOfDay); return cal.getTime(); }
From source file:Main.java
public static Date nextDay(Date date) { Calendar calendar = new GregorianCalendar(); calendar.setTime(date);/*from w ww . ja v a2 s . c o m*/ calendar.add(calendar.DATE, 1); date = calendar.getTime(); return date; }
From source file:emily.util.YTUtil.java
/** * Time until the next google api reset happens (Midnight PT), or 9am GMT * * @return formatted string, eg. "10 minutes form now" *//*ww w. jav a 2 s . c o m*/ public static String nextApiResetTime() { Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_MONTH, 0); c.set(Calendar.HOUR_OF_DAY, 9); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return TimeUtil.getRelativeTime( (System.currentTimeMillis() + (c.getTimeInMillis() - System.currentTimeMillis()) % TimeUnit.DAYS.toMillis(1)) / 1000L, false); }
From source file:org.ebaysf.ostara.upgrade.util.GitUtils.java
private static String getISODate(int i) { DateFormat df = new SimpleDateFormat("YYYY-MM-dd"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -i); String date = df.format(cal.getTime()); return date;//w w w.j a v a 2 s .c o m }
From source file:com.google.jenkins.plugins.credentials.oauth.P12ServiceAccountConfigTestUtil.java
private static X509Certificate generateCertificate(KeyPair keyPair) throws OperatorCreationException, CertificateException { Calendar endCalendar = Calendar.getInstance(); endCalendar.add(Calendar.YEAR, 10); X509v3CertificateBuilder x509v3CertificateBuilder = new X509v3CertificateBuilder( new X500Name("CN=localhost"), BigInteger.valueOf(1), Calendar.getInstance().getTime(), endCalendar.getTime(), new X500Name("CN=localhost"), SubjectPublicKeyInfo.getInstance(keyPair.getPublic().getEncoded())); ContentSigner contentSigner = new JcaContentSignerBuilder("SHA1withRSA").build(keyPair.getPrivate()); X509CertificateHolder x509CertificateHolder = x509v3CertificateBuilder.build(contentSigner); return new JcaX509CertificateConverter().setProvider("BC").getCertificate(x509CertificateHolder); }
From source file:com.intuit.tank.harness.functions.DateFunctions.java
/** * Get the date x days from now.//from www . j a v a 2 s .c o m * * e.g. #function.date.addDays.1.MM-dd-yyyy * * @param days * The number of days to add (negative number to remove) * @param format * The format of the response (MM-dd-yyyy, MMddyyyy, etc) * @return The new date */ private static String addDays(int days, @Nullable String format) { Calendar now = Calendar.getInstance(); now.add(Calendar.DAY_OF_YEAR, days); DateFormat formatter = getFormatter(format); return formatter.format(now.getTime()); }
From source file:io.github.bluemarlin.util.BluemarlineUtil.java
public static Date getDateInThePast(int days) { Date dateNow = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(dateNow);/*from www .jav a 2 s. c o m*/ cal.add(Calendar.DATE, -days); Date d = cal.getTime(); return d; }
From source file:com.ligadata.kamanja.consumer.Main.java
private static void startScheduledTasks() { Calendar alertsAggCal = Calendar.getInstance(); alertsAggCal.add(Calendar.MILLISECOND, START_SCHEDULED_TASK_AFTER); Timer timer = new Timer(); timer.schedule(new AlertsAggTimerTask(), alertsAggCal.getTime(), config.getLong(ConfigFields.ALERTS_AGG_TASK_PERIOD_MILLIES)); }/*from ww w .jav a2 s . co m*/
From source file:com.github.abhinavmishra14.aws.util.AWSUtil.java
/** * Gets the expiry date.<br/>//from ww w . j av a2s .c o m * Expire by parameter takes input as Calendar.Month, Calendar.Hour, Calendar.Minute etc. * * @param expireBy the expire by * @param expireByValue the expire by value * @return the expiry date * @see Calendar */ public static Date getExpiryDate(final int expireBy, final int expireByValue) { final Date currentDate = new Date(); final Calendar cal = Calendar.getInstance(); cal.setTime(currentDate); cal.add(expireBy, expireByValue); return cal.getTime(); }