简体   繁体   中英

Java date to postgres Timestamp without timezone

In my postgres database one of the table has Timestamp without timezone value

2019-04-30 06:58:39.140661

I have the entity class where it is generated like this:

@Temporal(TemporalType.TIMESTAMP)
@Column(name="updated_ts")
private java.util.Date updatedTs;

I need to fetch values from db but I have date as "MM/DD/YYY" . So, what I need is to just check the month day and year and ignore the rest.

Thanks in advance.

You can use

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/DD/YYYY") @Column(name="updated_ts") private java.util.Date updatedTs; or you can also use : @Temporal(value=TemporalType.DATE)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM