有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在Spring Boot中格式化时间戳字段?

我的实体中有timestamp字段,我想将此字段格式化为dd.MM HH:mm:ss

我的实体:

@Entity
@Table(name = "payloads")
public class Payload {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    @CreationTimestamp
    @DateTimeFormat(pattern = "dd.MM HH:mm:ss")
    @Column(name = "insert_date")
    private Timestamp insertDate;

    @Lob
    private String value;

似乎@DateTimeFormat不起作用,因为insert_date列的格式是payloads表中的yyyy-mm-dd hh:mm:ss

我的代码有什么问题?我如何解决这个问题


共 (0) 个答案