[英]How I could use Dates in Spring, in suitable Timezones for CRUD application?
I am trying to make a CRUD application,I have trouble on doing a new invoice.我正在尝试进行 CRUD 申请,但在开新发票时遇到了麻烦。 I get error in postman:
我在 postman 中遇到错误:
"org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement\r\n\tat org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java
It is possible to confuse the TimeZone of SQL and IntelliJ. SQL 和 IntelliJ 的 TimeZone 可能会混淆。 I don't know.
我不知道。
application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/mydatabase?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
or或者
spring.datasource.url=jdbc:mysql://localhost:3306/mydatabase?useSSL=false&serverTimezone=UTC
I have used ZonedDateTime
for dates always.我一直使用
ZonedDateTime
作为日期。 It can solve this i think.我认为它可以解决这个问题。 On Dto, you should say
String date;
在 Dto 上,你应该说
String date;
and on entity, you should say ZonedDateTime date;
在实体上,您应该说
ZonedDateTime date;
Spring can make all other job between convertion Spring 可以在转换之间完成所有其他工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.