0
我有春天休息服務項目,我使用JPA休眠和我面臨一個奇怪的問題在我的控制器。下面是代碼片段:春天控制器轉換時間到它的本地時區
控制器:
@RequestMapping(method = RequestMethod.POST, value=PATH_SEPERATOR+ CREATE_OR_UPDATE_EVENT_METHOD, headers = ACCEPT_APPLICATION_JSON, produces = APPLICATION_JSON)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody
ResponseBean createOrUpdateEvent(@RequestBody Event eventBean)
{
ResponseBean response = new ResponseBean();
try {
String sysId = eventService.createOrUpdateEvent(eventBean);
response.setStatus(OK);
response.setData(sysId);
} catch(Exception ex) {
response = handleException(CREATE_OR_UPDATE_EVENT_METHOD, ex);
return response;
}
return response;
}
Event.java
@Entity
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "sysId", scope = Event.class)
@Table(name = "event")
public class Event {
@Column(name = "date_time")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
private Date dateTime;
public Date getDateTime() {
return dateTime;
}
public void setDateTime(Date dateTime) {
this.dateTime = dateTime;
}
}
當我通過日期事件豆在createOrUpdateEvent
方法字符串「2014-04-17T17 :15:56「,這是在IST時區,控制器將其轉換爲日期,日期時間爲」2014-04-17T22:45:56「IST,考慮以前的時間爲UTC時間。我不明白這種自動轉換的行爲。我認爲這是因爲我接受參數爲bean,其中bean是JPA實體。請幫我解決它。