Skip to content
Merged
Changes from 1 commit
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 @@ -135,6 +135,7 @@
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.TimeZone;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -674,6 +675,15 @@ public static DateTimeZone randomDateTimeZone() {
return DateTimeZone.forID(randomFrom(ids));
}

/**
* generate a random TimeZone from the ones available in java.time
*/
public static TimeZone randomTimeZone() {
List<String> ids = Arrays.asList(TimeZone.getAvailableIDs());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these be statically loaded so calls to this do not each need to do a sort?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just looking at how we currently do this for the joda DateTimeZone in randomDateTimeZone, I think that method would benefit slighty as well from making the sorted IDs static. Would make sense to maybe change this in one go?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched them both to use statically initialized and sorted lists

Collections.sort(ids);
return TimeZone.getTimeZone(randomFrom(ids));
}

/**
* helper to randomly perform on <code>consumer</code> with <code>value</code>
*/
Expand Down