方式一:
修改配置文件(.yml):
spring:
#時(shí)間+8小時(shí)
? jackson:
date-format: java.text.SimpleDateFormat#或正則yyyy-MM-dd HH:mm:ss
time-zone: GMT+8#或UTC
方式二:
代碼配置:
```
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import javax.annotation.PostConstruct;
import java.util.TimeZone;
@SpringBootApplication
public class SpringBootStudyApplication {
//設(shè)置時(shí)區(qū) 相差8小時(shí)
@PostConstruct
void started() {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
public static void main(String[] args) {
SpringApplication.run(SpringBootStudyApplication.class, args);
}
}
————————————————
版權(quán)聲明:本文為CSDN博主「乄名007」的原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/qq_35119422/article/details/80573762
```