Hello!

Please tell me the best way to convert LocalDate to UTC before saving it to the MySQL database through MyBatis.

Interested in a place where it is better to perform the conversion in UTC and back to the user's time zone. I was thinking of doing it in TypeHandler, but I won’t be able to get it in my time zone.

    1 answer 1

    No need to convert. For MyBatis, there is a Type Handlers for JSR 310: Date and Time API Then use something like this:

    <select id="getFoo" resultType="java.time.LocalDate"> SELECT date from footable </select>