JPA entity: get the hours,minutes and sec from Oracle DATE column

前端 未结 2 401
醉酒成梦
醉酒成梦 2021-01-06 07:40

I have problems to get the full DATE info from my Oracle DB (dd/mm/yyyy hh/mm/ss).

In the db level, in the column that I want to receive I set test values:



        
相关标签:
2条回答
  • 2021-01-06 08:20

    By using the TIMESTAMP temporal type, you will get the date and the time part of the java date datatype but Oracle will make a column with the TIMESTAMP datatype. To overcome this issue if you want a DATE datatype, you can use the columnDefinition parameter of the column annotation such as:

    @Column(name = "MY_DATE_COLUMN", columnDefinition = "DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateDetailed;
    
    0 讨论(0)
  • 2021-01-06 08:26

    Its the TemporalType.DATE You will need TIME or TIMESTAMP. DATE is only the date without time. TIMESTAMP is represented as a number.

    0 讨论(0)
提交回复
热议问题