Reputation: 33
I'm using Hibernate. From the UI I'm getting the datetime as 2019-04-29 19:00:00
. The same value will be stored in my Oracle database but it is being saved as 2019-04-29 07:00:00
.
In Database camp_start_time Datatype is Timestamp
Adding code snippet:
{ "camp_id":292,"camp_name":
"Tata","camp_desc":"Tata","camp_type": 1,"camp_start_time":"2019-04-29 19:00:00"}
@Entity public class Campaign_Sms implements Serializable{
@Column(name = "CAMP_START_TIME") private Date camp_start_time; }
Upvotes: 1
Views: 1700
Reputation: 1490
Try the @Temporal(TemporalType.TIMESTAMP)
annotation with it.
@Temporal(TemporalType.TIMESTAMP)
private Date camp_start_time;
TemporalType.DATE
annotation value omit the time, as well as TemporalType.TIME
exclude the date. Check the document here.
UPDATE
Output format should be this yyyy-MM-dd hh:mm:ss a
and if output required as it is format should be yyyy-MM-dd HH:mm:ss
.
Upvotes: 2
Reputation: 401
use the @Temporal(TemporalType.DATE) annotation with it.
@Column
@Temporal(TemporalType.DATE)
private Date camp_start_time;
Upvotes: 0