0

I stored "06:00:00" in a SQL Server database as a time(0) type. Our time zone is "Australia/Sydney". How can I convert the time to "06:00" in Java code using Joda-Time?

I have tried the following:

@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalTime")
@Column private LocalTime openTime;

No matter how I format the time, it always is "16:00".

4
  • Welcome to StackOverflow! We would love to answer your question but it would help if we had more details of your code. Have a look at this and see if you can edit your question to provide some clarity. Dec 8, 2016 at 0:55
  • Fixed by add this @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalTime", parameters = { @Parameter(name = "databaseZone", value = "Australia/Sydney")}) don't know why, I guess this is a bug of usertype
    – UncleJ
    Dec 8, 2016 at 1:37
  • Great! maybe you can answer your own question to be of use to subsequent users? Dec 8, 2016 at 1:38
  • Yes, the current solution is @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalTime", parameters = { @Parameter(name = "databaseZone", value = "jvm")})
    – UncleJ
    Dec 12, 2016 at 1:07

1 Answer 1

0

(From the comment by @JohnLuan)

The correct solution is the following:

@Type(
    type = "org.jadira.usertype.dateandtime.joda.PersistentLocalTime",
    parameters = { @Parameter(name = "databaseZone", value = "jvm") }
 ) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.