public class DateAndTime extends Object
Modifier | Constructor and Description |
---|---|
protected |
DateAndTime(Faker faker) |
Modifier and Type | Method and Description |
---|---|
Date |
between(Date from,
Date to)
Generates a random date between two dates.
|
Date |
birthday()
Generates a random birthday between 65 and 18 years ago.
|
Date |
birthday(int minAge,
int maxAge)
Generates a random birthday between two ages.
|
Date |
future(int atMost,
int minimum,
TimeUnit unit)
Generates a future date from now, with a minimum time.
|
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,
int minimum,
TimeUnit unit)
Generates a past date from now, with a minimum time.
|
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 . |
protected DateAndTime(Faker faker)
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, int minimum, TimeUnit unit)
atMost
- at most this amount of time ahead from now exclusive.minimum
- the minimum amount of time in the future from now.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, int minimum, TimeUnit unit)
atMost
- at most this amount of time earlier from now exclusive.minimum
- the minimum amount of time in the past from now.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.public Date birthday()
public Date birthday(int minAge, int maxAge)
minAge
- the minimal agemaxAge
- the maximal ageminAge
and maxAge
years ago.IllegalArgumentException
- if the maxAge
is lower than minAge
.Copyright © 2019. All rights reserved.