我在项目Spring中使用Java 8日期时间, 但是当我显示那个日期时,我有:[object Object]
服务器:
class Person {
LocalDateTime dateCreation;
...
}
和
@RestController
public class PersonController {
@RequestMapping(value ="/getPerson", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public List<A> getPerson() {
return personRepository.findAll();
}
....
客户:
ngOnInit() {
this.PersonService.getPersons().subscribe(persons => this.persons = persons);
}
和
export class Person {
....
dateCreation:Date;
}
和person.html:
<p-dataTable [value]="persons" ...>
<p-column field="dateCreation" header="DateCreation" [sortable]="true">
<template let-col let-person="rowData" pTemplate="body">
{{person.dateCreation|date}}
</template>
</p-column>
答案 0 :(得分:1)
感谢pdem,这个链接解决了我的问题 我正在使用:
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonFormat(pattern="dd/MM/yyyy hh:mm")
private LocalDateTime dateCreation = ...