public abstract class PrimaryBaseEntity {
@JsonFormat(pattern = "dd-MM-yyyy hh:mm:ss")
@Column(name = "rejected_date")
private ZonedDateTime rejectedDate;
}
//Extended above class
public class CountryChecker extends PrimaryBaseEntity
in application.yml below property added.
spring:
profiles:
active: dev
include: SeperateDatabase,no-liquibase
devtools:
restart:
enabled: false
livereload:
enabled: false # we use gulp + BrowserSync for livereload
jackson:
#serialization.indent_output: true
serialization.WRITE_DATES_AS_TIMESTAMPS: false
仍然以低于日期格式回复JSON “rejectedDate”:1519828549,
这是JHIPSter生成的项目,请告诉我我们需要做些什么改变。
答案 0 :(得分:0)
尝试在application.properties文件中提及此内容
spring.jackson.date-format= # Date format string (e.g. yyyy-MM-dd HH:mm:ss)
或
你可以使用getter方法将时间戳解析为“dd-MM-yyyy hh:mm:ss”
public abstract class PrimaryBaseEntity {
@Column(name = "rejected_date")
private ZonedDateTime rejectedDate;
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
public Date getRejectedDate() {
return formatter.parse(rejectedDate);
}
}