[英]Store DateTime column in h2 database by hibernate
I want to store DateTime column in h2 database by hibernate ,spring mvc and angularJs I can save the following date format 2015-01-14 but I want to store this format 2015-01-14 21:32:29 but I get this error POST http://loclhost:8080/pagingpoc/app/rest/contacts [HTTP/1.1 400 Bad Request 24ms] 我想将hibernate,spring mvc和angularJs的DateTime列存储在h2数据库中,我可以保存以下日期格式2015-01-14,但是我想存储此格式2015-01-14 21:32:29但我遇到此错误POST http:// loclhost:8080 / pagingpoc / app / rest / contacts [HTTP / 1.1 400错误请求24ms]
field declaration in entity 实体中的字段声明
@Column(name = "updatetimestamp", nullable = false)
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
private DateTime updatetimestamp;
Column name and type in database table 列名和数据库表中的类型
<column name="UpdateTimestamp" type="timestamp"/>
Spring controller 弹簧控制器
@RequestMapping(value = "/rest/contacts",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public void create(@RequestBody Contact contact) {
contactRepository.save(contact);
}
AngularJS service AngularJS服务
pagingpocApp.factory('Contact', function ($resource) {
return $resource('app/rest/contacts/:id', {}, {
'query': { method: 'GET', isArray: true},
'get': { method: 'GET'}
});
});
AngularJS controller AngularJS控制器
$scope.create = function () {
Contact.save($scope.contact,
function () {
$scope.contacts = Contact.query();
$('#saveContactModal').modal('hide');
$scope.clear();
});
};
Html page HTML页面
<div class="form-group">
<label>Update Timestamp</label>
<input type="text" class="form-control"
ng-model="contact.updatetimestamp">
</div>
您应该以这种格式输入DateTime 2015-01-14T21:32:29
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.