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

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.

Do you know how to do this conversion?

@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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.