public class DateAndTime extends Object
| Modifier and Type | Method and Description |
|---|---|
Date |
between(Date from,
Date to)
Generates a random date between two dates.
|
Date |
future(int atMost,
TimeUnit unit)
Generates a future date from now.
|
Date |
future(int atMost,
TimeUnit unit,
Date referenceDate)
Generates a future date relative to the
referenceDate. |
Date |
past(int atMost,
TimeUnit unit)
Generates a past date from now.
|
Date |
past(int atMost,
TimeUnit unit,
Date referenceDate)
Generates a past date relative to the
referenceDate. |
public Date future(int atMost, TimeUnit unit)
atMost - at most this amount of time ahead from now exclusive.unit - the time unit.public Date future(int atMost, TimeUnit unit, Date referenceDate)
referenceDate.atMost - at most this amount of time ahead to the referenceDate exclusive.unit - the time unit.referenceDate - the future date relative to this date.referenceDate.public Date past(int atMost, TimeUnit unit)
atMost - at most this amount of time earlier from now exclusive.unit - the time unit.public Date past(int atMost, TimeUnit unit, Date referenceDate)
referenceDate.atMost - at most this amount of time past to the referenceDate exclusive.unit - the time unit.referenceDate - the past date relative to this date.referenceDate.public Date between(Date from, Date to) throws IllegalArgumentException
from - the lower bound inclusiveto - the upper bound exclusivefrom and to.IllegalArgumentException - if the to date represents an earlier date than from date.Copyright © 2016. All Rights Reserved.