Package de.cuioss.test.generator.impl
Class ZonedDateTimeGenerator
java.lang.Object
de.cuioss.test.generator.impl.ZonedDateTimeGenerator
- All Implemented Interfaces:
TypedGenerator<ZonedDateTime>
Generates
ZonedDateTime instances with random dates, times, and time zones.
This generator combines date generation with zone ID generation to create complete
zoned date-time values.
Features:
- Generates valid ZonedDateTime instances
- Uses
Generators.dates()for the date-time component - Uses
Generators.zoneIds()for the time zone component - Provides utility methods for common test scenarios
- Thread-safe implementation
Example usage:
// Using the generator directly var generator = new ZonedDateTimeGenerator(); ZonedDateTime dateTime = generator.next(); // Using convenience methods ZonedDateTime any = ZonedDateTimeGenerator.any(); ZonedDateTime future = ZonedDateTimeGenerator.future(); ZonedDateTime past = ZonedDateTimeGenerator.past();
This generator is particularly useful for testing:
- Time zone conversions
- Date-time formatting and parsing
- Temporal calculations across time zones
- Author:
- Eugen Fischer
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ZonedDateTimeany()getType()Provides type information about what kind of objects this generator creates.static ZonedDateTimestatic ZonedDateTimenext()Generates the next instance based on the generator's configuration.static ZonedDateTimenow()static ZonedDateTimestatic ZonedDateTimestatic ZonedDateTimestatic ZonedDateTimestatic ZonedDateTimestatic ZonedDateTime
-
Constructor Details
-
ZonedDateTimeGenerator
public ZonedDateTimeGenerator()
-
-
Method Details
-
next
Description copied from interface:TypedGeneratorGenerates the next instance based on the generator's configuration. Implementations must ensure thread-safety.- Specified by:
nextin interfaceTypedGenerator<ZonedDateTime>- Returns:
- A newly created instance. May be null if the generator explicitly supports null value generation.
-
getType
Description copied from interface:TypedGeneratorProvides type information about what kind of objects this generator creates. The default implementation uses the first non-null result fromTypedGenerator.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:
getTypein interfaceTypedGenerator<ZonedDateTime>- Returns:
- The class information indicating which type this generator is responsible for.
-
any
- Returns:
- an arbitrary ZonedDateTime
-
now
- Returns:
- value of ZonedDateTime for now
-
someMinutesAgo
- Returns:
- value of ZonedDateTime one hour ago
-
someHoursAgo
- Returns:
- value of ZonedDateTime one hour ago
-
someDaysAgo
- Returns:
- value of ZonedDateTime one day ago
-
someWeeksAgo
- Returns:
- value of ZonedDateTime one week ago
-
someMonthsAgo
- Returns:
- value of ZonedDateTime one month ago
-
someYearsAgo
- Returns:
- value of ZonedDateTime one year ago
-
lastTenYearsAgo
- Returns:
- value of ZonedDateTime with date somewhere 10 years ago
-
lastMonthAgo
- Returns:
- value of ZonedDateTime with date somewhere lastMonth
-