TimeZone discrepancy in mysql and java

前端 未结 5 476
生来不讨喜
生来不讨喜 2021-01-18 05:36

I have a query in mysql which compares 2 dates like this

convert_tz(updatedDate,\'+05:30\',\'-05:00\') < ?

the convert function returns

5条回答
  •  生来不讨喜
    2021-01-18 06:32

    Give this a try.

    Set timestamp parameter as you are setting now

    pst.setTimestamp(1, new java.sql.Timestamp(end.getTimeInMillis()));
    

    .

    During database call, JDBC driver may already be converting input date/time values to GMT. So the date value that database is dealing with won't have to take timezones of input date into considerations which may differ from one client to other.

    Instead of setting from_tz as '+05:30'

    convert_tz(updatedDate,'+05:30','-05:00')
    

    Set from_tz as '00:00'

    convert_tz(updatedDate,'00:00','-05:00') 
    

提交回复
热议问题