This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 3952780fd797b344e5752077fc61c0e0907ec158 Author: Gary Gregory <[email protected]> AuthorDate: Sun Mar 20 14:27:50 2022 -0400 Adds TimeZones.toTimeZone(). --- src/main/java/org/apache/commons/lang3/time/TimeZones.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/lang3/time/TimeZones.java b/src/main/java/org/apache/commons/lang3/time/TimeZones.java index 4f7a009..770e1cc 100644 --- a/src/main/java/org/apache/commons/lang3/time/TimeZones.java +++ b/src/main/java/org/apache/commons/lang3/time/TimeZones.java @@ -26,7 +26,7 @@ import java.util.TimeZone; */ public class TimeZones { - // Do not instantiate. + /** Do not instantiate. */ private TimeZones() { } @@ -41,4 +41,16 @@ public class TimeZones { * @since 3.13.0 */ public static final TimeZone GMT = TimeZone.getTimeZone(GMT_ID); + + /** + * Returns the given TimeZone if non-{@code null}, otherwise {@link TimeZone#getDefault()}. + * + * @param timeZone a locale or {@code null}. + * @return the given locale if non-{@code null}, otherwise {@link TimeZone#getDefault()}. + * @since 3.13.0 + */ + public static TimeZone toTimeZone(final TimeZone timeZone) { + return timeZone != null ? timeZone : TimeZone.getDefault(); + } + }
