韩国网站源码下载,自己做视频网站可以吗,建设网站教学,google图片搜索最近项目遇到一个坑#xff0c;就是server和db之间存在时区问题#xff0c;本人的db是utc时间#xff0c; 可以使用代码设置时区来解决#xff0c;本人这里使用joda三方包#xff0c;joda蛮好用的#xff0c;具体用法这里不做详细描述。 先引入pom dependency就是server和db之间存在时区问题本人的db是utc时间 可以使用代码设置时区来解决本人这里使用joda三方包joda蛮好用的具体用法这里不做详细描述。 先引入pom dependencygroupIdjoda-time/groupIdartifactIdjoda-time/artifactIdversion2.10.1/version
/dependency 下面在使用的地方加上下面一句即可。 // 这里使用UTC还有其他的配置参数比如 Asia/Shanghai Asia/Chongqin 等等DateTime utcDT new DateTime().withZone(DateTimeZone.UTC).toLocalDateTime().toDateTime();...
...
...UserDto dto new UserDto();
dto.setCreated(utcDT.toDate());
userMapping.insertRecords(dto); 除了上面的方法外还可以在驱动器的连接URL上加参数如下 spring.datasource.driver-class-namecom.mysql.jdbc.Driver
spring.datasource.urljdbc:mysql://127.0.0.1:3306/xxx?useUnicodetruecharacterEncodingutf8 allowMultiQueriestrueuseLegacyDatetimeCodefalseserverTimezoneUTC
spring.datasource.usernameroot
spring.datasource.password111111 说明useLegacyDatetimeCodefalse 关键是这个参数引用http://www.voidcn.com/article/p-eqvuhiio-bsb.html 这里有详细的介绍 附上mysql官网文档https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html转载于:https://www.cnblogs.com/jimmyshan-study/p/10974926.html