Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,12 @@ private static String randomSeparator() {
}

private static String randomTimestamp() {
long millis = randomMillisUpToYear9999();
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(millis), randomZone());
// The random millis are below year 10000 in UTC, but if the date is within 1 day of year 10000, the year can be 10000 in the
// selected timezone. Since the date formatter cannot handle years greater than 9999, select another date.
var zonedDateTime = randomValueOtherThanMany(
t -> t.getYear() == 10000,
() -> ZonedDateTime.ofInstant(Instant.ofEpochMilli(randomMillisUpToYear9999()), randomZone())
);
DateFormatter formatter = DateFormatter.forPattern(randomDateFormatterPattern()).withLocale(randomLocale(random()));
return formatter.format(zonedDateTime);
}
Expand Down