Annotation Interface DefaultTimeZone
@DefaultTimeZone is a JUnit Jupiter extension for changing the value
returned by TimeZone.getDefault() for a test execution.
The TimeZone to set as the default TimeZone is configured
by specifying the TimeZone ID as defined by
TimeZone.getTimeZone(String). After the annotated element has been
executed, the default TimeZone will be restored to its original
value.
@DefaultTimeZone can be used on the method and on the class
level. It is inherited from higher-level containers, but can only be used
once per method or class. If a class is annotated, the configured
TimeZone will be the default TimeZone for all tests inside
that class. Any method level configurations will override the class level
default TimeZone.
During
parallel test execution,
all tests annotated with @DefaultTimeZone,
@ReadsDefaultTimeZone, and
@WritesDefaultTimeZone are scheduled in a way that
guarantees correctness under mutation of shared global state.
For more details and examples, see the User Guide.
- Since:
- 6.1
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<? extends TimeZoneProvider> A class implementingTimeZoneProviderto be used for customTimeZoneresolution.The ID for aTimeZone, either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "GMT-8:00".
-
Element Details
-
value
String valueThe ID for aTimeZone, either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "GMT-8:00". Note that the support of abbreviations is for JDK 1.1.x compatibility only and full names should be used.- Default:
""
-
timeZoneProvider
Class<? extends TimeZoneProvider> timeZoneProviderA class implementingTimeZoneProviderto be used for customTimeZoneresolution. This is mutually exclusive with other properties, if any other property is given a value it will result in anExtensionConfigurationException.- Default:
org.junit.jupiter.api.util.NullTimeZoneProvider.class
-