将JSON对象的时间值(以毫秒为单位)格式化为日期并在视图中呈现此内容的最佳方法是什么。出于某种原因,angular似乎没有正确格式化,因此输入字段保持为空?
hibernate实体将通过REST返回为JSON。
实体帐户:
@Entity
@Table(name = "account")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Account extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "NAME")
private String name;
@Column(name = "EMAIL")
private String email;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "BIRTHDAY")
...
REST WS:
@RequestMapping(value = "upsert", method = RequestMethod.POST)
public ResponseEntity<Account> upsert(@RequestBody Account account) {
Account response = accountAccess.upsert(account);
return new ResponseEntity<>(response, HttpStatus.OK);
}
角度帐户控制器:
$scope.updateAccount = function(flow) {
$http.post("rest/account/upsert", $scope.account)
.success(function(response) {
$scope.account = response;
$localStorage.account = response;
toaster.pop('success', "Account saved", "Your data was succesfully saved.")
})
.error(function(error){
toaster.pop('error', "Account not saved", "Your data could not be saved.")
})
}
帐户HTML:
<div class="form-group">
<label class="col-sm-2 control-label">Date</label>
<div class="col-sm-10">
<div class="input-group date">
<input id="birthday" type="date" class="form-control" ng-model="account.birthday | date" datepicker-options="dateOptions" close-text="Close" />
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>