Java TimeUnit Convert getDateRelativeToNow(TimeUnit timeUnit, long amount)

Here you can find the source of getDateRelativeToNow(TimeUnit timeUnit, long amount)

Description

Builds and returns a date that is a specified amount of time away from now (earlier or later).

License

Open Source License

Declaration

public static Date getDateRelativeToNow(TimeUnit timeUnit, long amount) 

Method Source Code

//package com.java2s;

import java.util.Date;

import java.util.concurrent.TimeUnit;

public class Main {
    /**//www .java 2  s.  c  om
     * Builds and returns a date that is a specified amount of time away from now (earlier or later).
     */
    public static Date getDateRelativeToNow(TimeUnit timeUnit, long amount) {
        return new Date(System.currentTimeMillis() + timeUnit.toMillis(amount));
    }
}

Related

  1. convertToDouble(long fromTime, TimeUnit fromTimeUnit, TimeUnit toTimeUnit)
  2. convertToMillis(long waitTime, TimeUnit timeUnit)
  3. convertToMilliseconds(TimeUnit timeUnit, long seed)
  4. convertToSecond(int interval, TimeUnit unit)
  5. durationToMillis(final long val, final TimeUnit unit)
  6. getRemainingTimeToday(final TimeUnit timeUnit)
  7. hoursToUnit(double hours, TimeUnit destinationUnit)
  8. millisecondsTo(long milliseconds, final TimeUnit timeUnit)
  9. millisToDuration(final int val, final TimeUnit unit)