实体
package com.zj.blog.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import java.util.Date;
@Entity
public class Comment {
@Id
@GeneratedValue
private Long id;
private String content;
private String username;
@JSONField(format = "yyyy-MM-dd hh:mm:ss")
private Date create_time;
@ManyToOne
private Blog blog;
}
方案
只需要在对应的属性上添加
@JSONField(format = "yyyy-MM-dd hh:mm:ss")
注解即可