-
@Retention(RUNTIME) @Target({METHOD,TYPE}) @Inherited @ExtendWith(DefaultTimeZoneExtension.class) public @interface DefaultTimeZone@DefaultTimeZoneis a JUnit Jupiter extension to change the value returned byTimeZone.getDefault()for a test execution.The
TimeZoneto set as the defaultTimeZoneis configured by specifying theTimeZoneID as defined byTimeZone.getTimeZone(String). After the annotated element has been executed, the defaultTimeZonewill be restored to its original value.@DefaultTimeZonecan 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 configuredTimeZonewill be the defaultTimeZonefor all tests inside that class. Any method level configurations will override the class level defaultTimeZone.During parallel test execution, all tests annotated with
DefaultTimeZone,ReadsDefaultTimeZone, andWritesDefaultTimeZoneare scheduled in a way that guarantees correctness under mutation of shared global state.For more details and examples, see the documentation on
@DefaultLocaleand@DefaultTimeZone.- Since:
- 0.2
- See Also:
TimeZone.getDefault(),DefaultLocale
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.StringvalueThe 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".
-