aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/core/generators.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/xyz/driver/core/generators.scala')
-rw-r--r--src/main/scala/xyz/driver/core/generators.scala7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/scala/xyz/driver/core/generators.scala b/src/main/scala/xyz/driver/core/generators.scala
index d57980e..d00b6dd 100644
--- a/src/main/scala/xyz/driver/core/generators.scala
+++ b/src/main/scala/xyz/driver/core/generators.scala
@@ -2,6 +2,7 @@ package xyz.driver.core
import enumeratum._
import java.math.MathContext
+import java.time.{Instant, LocalDate, ZoneOffset}
import java.util.UUID
import xyz.driver.core.time.{Time, TimeOfDay, TimeRange}
@@ -88,7 +89,9 @@ object generators {
def nextTriad[F, S, T](first: => F, second: => S, third: => T): (F, S, T) = (first, second, third)
- def nextTime(): Time = Time(math.abs(nextLong() % System.currentTimeMillis))
+ def nextInstant(): Instant = Instant.ofEpochMilli(math.abs(nextLong() % System.currentTimeMillis))
+
+ def nextTime(): Time = nextInstant()
def nextTimeOfDay: TimeOfDay = TimeOfDay(java.time.LocalTime.MIN.plusSeconds(nextLong), java.util.TimeZone.getDefault)
@@ -103,6 +106,8 @@ object generators {
def nextDate(): Date = nextTime().toDate(java.util.TimeZone.getTimeZone("UTC"))
+ def nextLocalDate(): LocalDate = nextInstant().atZone(ZoneOffset.UTC).toLocalDate
+
def nextDayOfWeek(): DayOfWeek = oneOf(DayOfWeek.All)
def nextBigDecimal(multiplier: Double = 1000000.00, precision: Int = 2): BigDecimal =