Skip to content

add Temporal faker for java.time-based date/time generation #50

Description

@TheJavaGuy

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions