0
点赞
收藏
分享

微信扫一扫

springboot配置全局时区

Ichjns 2022-03-21 阅读 39
spring boot

自定义一个全局时区配置类

package com.stone.bigdata.config;

import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import java.time.ZoneOffset;
import java.util.TimeZone;

/**
 * 全局时区
 * @author yanchi
 * @date 2022/3/20 11:40
 */
@Configuration
public class GlobalZoneConfig {
    @PostConstruct
    void started() {
        //时区设置:中国上海(东八区)
        TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.of("+8")));
    }
}

举报

相关推荐

0 条评论