문제 : 데이터베이스에 잘못된 시간이 있습니다. 응용 프로그램 서버에 문제가 있습니다.날짜가 올바르지 만 mysql [time zone]에 잘못되었습니다.
중국 거주 기간은 UTC + 8입니다. 최대 절전 모드입니다. 다음과 같은 엔티티 정의 (언어 : Scala)
class CargoJournal {
@Type(`type`="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
var deliverTime: LocalDateTime = _
@Temporal(TemporalType.TIMESTAMP)
@Column(nullable=false)
var logDate:Date = _
}
최대 절전 모드 로그를 열 때, 내 응용 프로그램 서버에서 다음을 참조하십시오.
mysql> select timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00'));
+----------------------------------------------------------------+
| timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00')) |
+----------------------------------------------------------------+
| 08:00:00 |
+----------------------------------------------------------------+
그래서 MySQL의 시간대가 맞다 : 현재 시간은 목 9월 13일 중부 표준시 11시 08분 44초 내 데이터베이스 서버에서 2012
insert into wms_history_cargo_journal (deliver_time, log_date)
binding parameter [1] as [TIMESTAMP] - 2012-09-13 11:08:44.25
binding parameter [2] as [TIMESTAMP] - Thu Sep 13 11:08:44 CST 2012
입니다. MySQL의에서 선택 후 UTC + 8
:
mysql> SELECT deliver_time, log_date FROM wms_history_cargo_journal;
+---------------------+---------------------+
| deliver_time | log_date |
+---------------------+---------------------+
| 2012-09-13 11:08:44 | 2012-09-13 03:08:44 |
+---------------------+---------------------+
는 log_date 잘못입니다!
왜'logDate' 필드에'@Type (type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")'주석이 없습니까? 'deliverTime'이'LocalDateTime' 데이터 유형과 해당 주석으로 인해 예상대로 작동한다고 가정하지만 비슷한 매핑이 없기 때문에'logDate'가 작동하지 않습니다? –