set-timezone
set-timezone copied to clipboard
Java Timezone setting does not work in ubuntu-latest any more
We have a groovy(JDK) project which runs tests which depend on the time zone. We use the set-timezone action to pin the time zone. Previously, ubuntu-latest was using Ubuntu 22.04 (see https://github.com/actions/runner-images/issues/10636) and it worked fine. Now, ubuntu-latest is using Ubuntu-24.04 and our builds fail because the java default time zone is set to Etc/UTC instead of Europe/Berlin as requested in the settings of set-timezone.
The set-timezone step within the Workflow is the first step in the workflow and is configured as follows:
- uses: szenius/[email protected]
with:
timezoneLinux: "Europe/Berlin"
timezoneMacos: "Europe/Berlin"
timezoneWindows: "W. Europe Standard Time"
The test is:
import spock.lang.Specification
import java.time.ZoneId
class TimezoneSpecification extends Specification {
def "Check Timezone"() {
when:
TimeZone timeZone = TimeZone.getDefault();
then:
timeZone.toZoneId() == ZoneId.of("Europe/Berlin")
}
}
The test fails with:
Condition not satisfied:
timeZone.toZoneId() == ZoneId.of("Europe/Berlin")
| | | | |
| Etc/UTC | | Europe/Berlin
| | class java.time.ZoneId
| false
sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
at TimezoneSpecification.Check Timezone(TimezoneSpecification.groovy:13)