我试过了
user.timezone=UTC 在 config/application.propertiesuser.timezone=GMT在pom.xml中:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<properties>
<spring-boot.run.jvmArguments>-Duser.timezone=UTC</spring-boot.run.jvmArguments>
</properties>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)但它打印出来
System.out.println(TimeZone.getDefault());
Run Code Online (Sandbox Code Playgroud)
sun.util.calendar.ZoneInfo [id =“ America / New_York”,offset = -18000000,dstSavings = 3600000,useDaylight = true,transitions = 235,lastRule = java.util.SimpleTimeZone [id = America / New_York,offset =- 18000000,dstSavings = 3600000,useDaylight = true,startYear = 0,startMode = 3,startMonth = 2,startDay = 8,startDayOfWeek = 1,startTime = 7200000,startTimeMode = 0,endMode = …