0

I am using jodatime for datetime. When I persist the date in mysql it stores 2015-09-04 10:30:18 instead of 2015-09-04 14:30:18. My timezone is GMT+4 or UAE. Do you know how to change the timezone? I try to put GMT+4 but it does not work. I run this line on mysql

select now()

and it gives me the correct date and time.

Entity class below:

 @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime", parameters = { @Parameter(name = "databaseZone", value = "UTC"), @Parameter(name = "javaZone", value = "jvm")})
@Column(name = "CURRENT_DATE")
@Basic(fetch = FetchType.EAGER)
@XmlElement
DateTime currentDate;

The problem is only when it saves the datetime in mysql. If I have to retrieve the date from mysql to do some calculation, the date is correct that it will be 2015-09-04 14:30:18. But when it will store , it is 2015-09-04 10:30:18.
Glad if you can help to sort this out.
Thanks

3
Contributors
4
Replies
36
Views
2 Years
Discussion Span
Last Post by samantha2015
0

the timestamp is stored in UTC, which is normal, especially if the server is running on Unix.
It's up to you to do the conversion if needed.

0

@Parameter(name = "databaseZone", value = "UTC")

Did you try to change this? Jadira defaults to using UTC in the database, and the JVM zone in the application.

0

I need to use timezone GMT+4 or UAE. I try to input GMT+4... and it's not correct!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.