Overview
The Temporal faker generates random date/time values using the modern Java 8+ java.time API. It complements the existing DateAndTime provider (which uses legacy java.util.Date/Calendar) without modifying it.
Use Cases
- Testing systems that use
java.time types (Instant, LocalDateTime, LocalDate, etc.)
- Generating realistic timestamps for event sourcing and audit logs
- Creating random scheduling data (appointments, bookings, reservations)
- Birthday and age-related test data using
LocalDate
- Duration and period generation for SLA/timeout testing
- Timezone-aware test scenarios
Files to create/modify
| Component |
Path |
| Java Class |
src/main/java/org/thejavaguy/javafaker/Temporal.java |
| Test Class |
src/test/java/org/thejavaguy/javafaker/TemporalTest.java |
| Registration |
src/main/java/org/thejavaguy/javafaker/Faker.java |
No YAML file needed — all methods are purely algorithmic.
Methods
futureInstant(long atMost, ChronoUnit unit) — future Instant
futureInstant(long atMost, long minimum, ChronoUnit unit) — future Instant with minimum
futureInstant(long atMost, ChronoUnit unit, Instant referenceInstant) — future Instant relative to reference
pastInstant(...) — corresponding past variants
instantBetween(Instant from, Instant to) — random Instant in range
futureLocalDateTime / pastLocalDateTime / localDateTimeBetween — LocalDateTime variants
futureLocalDate / pastLocalDate / localDateBetween / birthdayLocalDate — LocalDate variants
localTime() — random LocalTime
duration(long maxSeconds) — random Duration
period(int maxDays) — random Period
zoneId() — random IANA ZoneId
Overview
The Temporal faker generates random date/time values using the modern Java 8+
java.timeAPI. It complements the existingDateAndTimeprovider (which uses legacyjava.util.Date/Calendar) without modifying it.Use Cases
java.timetypes (Instant,LocalDateTime,LocalDate, etc.)LocalDateFiles to create/modify
src/main/java/org/thejavaguy/javafaker/Temporal.javasrc/test/java/org/thejavaguy/javafaker/TemporalTest.javasrc/main/java/org/thejavaguy/javafaker/Faker.javaNo YAML file needed — all methods are purely algorithmic.
Methods
futureInstant(long atMost, ChronoUnit unit)— future InstantfutureInstant(long atMost, long minimum, ChronoUnit unit)— future Instant with minimumfutureInstant(long atMost, ChronoUnit unit, Instant referenceInstant)— future Instant relative to referencepastInstant(...)— corresponding past variantsinstantBetween(Instant from, Instant to)— random Instant in rangefutureLocalDateTime / pastLocalDateTime / localDateTimeBetween— LocalDateTime variantsfutureLocalDate / pastLocalDate / localDateBetween / birthdayLocalDate— LocalDate variantslocalTime()— random LocalTimeduration(long maxSeconds)— random Durationperiod(int maxDays)— random PeriodzoneId()— random IANA ZoneId