Package net.datafaker.providers.base
Class Time
- Since:
- 1.4.0
-
Field Summary
Fields inherited from class net.datafaker.providers.base.AbstractProvider
faker
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
Generates a random time between two times.Generates a string representation of a random time between two times.long
future
(int atMost, int minimum, ChronoUnit unit) Generates a future time from now, with a minimum time.future
(int atMost, int minimum, ChronoUnit unit, String pattern) Generates and converts to string representation of a future time from now, with a minimum time.long
future
(int atMost, ChronoUnit unit) Generates a future time from now.future
(int atMost, ChronoUnit unit, String pattern) Generates and converts to string representation a future time from now.long
past
(int atMost, int minimum, ChronoUnit unit) Generates a past time from now, with a minimum time.past
(int atMost, int minimum, ChronoUnit unit, String pattern) Generates and converts to string representation a past time from now, with a minimum time.long
past
(int atLeast, ChronoUnit unit) Generates a past time from now.past
(int atMost, ChronoUnit unit, String pattern) Generates a string representation of a past time from now.
-
Constructor Details
-
Time
-
-
Method Details
-
future
Generates a future time from now. Note that there is a 1 second slack to avoid generating a past time.- Parameters:
atMost
- at most this amount of time ahead from now exclusive.unit
- the time unit.- Returns:
- a future time from now.
-
future
Generates and converts to string representation a future time from now. Note that there is a 1 second slack to avoid generating a past time.- Parameters:
atMost
- at most this amount of time ahead from now exclusive.unit
- the time unit.pattern
- time pattern to convert to string.- Returns:
- a string representation of a future time from now.
-
future
Generates a future time from now, with a minimum time.- Parameters:
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.- Returns:
- a future time from now, with a minimum time.
-
future
Generates and converts to string representation of a future time from now, with a minimum time.- Parameters:
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.pattern
- time pattern to convert to string.- Returns:
- a string representation of a future time from now, with a minimum time.
-
past
Generates a past time from now. Note that there is a 1 second slack added.- Parameters:
atLeast
- at most this amount of time earlier from now exclusive.unit
- the time unit.- Returns:
- a past time from now.
-
past
Generates a string representation of a past time from now. Note that there is a 1 second slack added.- Parameters:
atMost
- at most this amount of time earlier from now exclusive.unit
- the time unit.pattern
- time pattern to convert to string.- Returns:
- a string representation of a past time from now.
-
past
Generates a past time from now, with a minimum time.- Parameters:
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.- Returns:
- a past time from now.
-
past
Generates and converts to string representation a past time from now, with a minimum time.- Parameters:
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.pattern
- time pattern to convert to string.- Returns:
- a string representation of a past time from now, with a minimum time.
-
between
Generates a random time between two times.- Parameters:
from
- the lower bound inclusiveto
- the upper bound exclusive- Returns:
- a random time between
from
andto
. - Throws:
IllegalArgumentException
- if theto
time represents an earlier time thanfrom
time.
-
between
Generates a string representation of a random time between two times.- Parameters:
from
- the lower bound inclusiveto
- the upper bound exclusivepattern
- time pattern to convert to string.- Returns:
- a string representation of a random time between
from
andto
. - Throws:
IllegalArgumentException
- if theto
time represents an earlier time thanfrom
time.
-