Class LocalDateGenerator

java.lang.Object
de.cuioss.test.generator.impl.LocalDateGenerator
All Implemented Interfaces:
TypedGenerator<LocalDate>

public class LocalDateGenerator extends Object implements TypedGenerator<LocalDate>
Generates LocalDate instances within a reasonable range around the epoch. The generator creates dates between approximately 63 years before and after the epoch (1970-01-01), providing a good range for most testing scenarios.

Features:

  • Generates dates from -23000 to +23000 days from epoch
  • Covers dates from roughly 1907 to 2033
  • Even distribution across the range
  • Thread-safe implementation

Example usage:

 
 // Create a generator
 var generator = new LocalDateGenerator();
 
 // Generate single values
 LocalDate date = generator.next();
 
 // Generate collections
 var collectionGen = new CollectionGenerator&lt;&gt;(generator);
 List&lt;LocalDate&gt; dates = collectionGen.list(5); // List of 5 dates
 
 

This generator is particularly useful for testing:

  • Date formatting and parsing
  • Date calculations and comparisons
  • Business logic involving dates
Author:
Eugen Fischer
See Also:
  • Constructor Details

  • Method Details

    • next

      public LocalDate next()
      Description copied from interface: TypedGenerator
      Generates the next instance based on the generator's configuration. Implementations must ensure thread-safety.
      Specified by:
      next in interface TypedGenerator<LocalDate>
      Returns:
      A newly created instance. May be null if the generator explicitly supports null value generation.
    • getType

      public Class<LocalDate> getType()
      Description copied from interface: TypedGenerator
      Provides type information about what kind of objects this generator creates. The default implementation uses the first non-null result from TypedGenerator.next() to determine the type.

      Note: If your generator may return null values or the generated type differs from the actual instance type, you should override this method.

      Specified by:
      getType in interface TypedGenerator<LocalDate>
      Returns:
      The class information indicating which type this generator is responsible for.