Java TimeUnit Calculate getFutureDate(long delay, TimeUnit timeUnit)

Here you can find the source of getFutureDate(long delay, TimeUnit timeUnit)

Description

get Future Date

License

Apache License

Declaration

public static Date getFutureDate(long delay, TimeUnit timeUnit) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Date;

import java.util.concurrent.TimeUnit;

public class Main {
    public static Date getFutureDate(long delay, TimeUnit timeUnit) {
        if (delay > 0) {
            return new Date(new Date().getTime() + TimeUnit.MILLISECONDS.convert(delay, timeUnit));
        } else {//from  w  ww  .j a va  2s  . c o m
            return new Date();
        }
    }
}

Related

  1. getDateDiff(Date date1, Date date2, TimeUnit timeUnit)
  2. getDateDiff(final Date d1, final Date d2, final TimeUnit timeUnit)
  3. getDifference(Calendar initDate, Calendar endDate, TimeUnit units)
  4. getExpiringMap(long time, TimeUnit unit)
  5. getFragment(final Calendar calendar, final int fragment, final TimeUnit unit)
  6. getInterval(final Date startDate, final Date endDate, final TimeUnit timeUnit)
  7. getIntervalInfo(long intervalDuration, TimeUnit unit)
  8. getMilliseconds(int interval, TimeUnit unit)
  9. getNowTimeUnit(TimeUnit timeUnit)