mybatis low version jsr310 (LocalDateTime, LocalDate etc.) Joda Time Support

<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

    <settings>
        <!--映射下划线风格到驼峰风格-->
        <setting name="mapUnderscoreToCamelCase" value="true"/>
    </settings>
    <typeHandlers>
        <typeHandler handler="org.apache.ibatis.type.InstantTypeHandler" />
        <typeHandler handler="org.apache.ibatis.type.LocalDateTimeTypeHandler" />
        <typeHandler handler="org.apache.ibatis.type.LocalDateTypeHandler" />
        <typeHandler handler="org.apache.ibatis.type.LocalTimeTypeHandler" />
        <typeHandler handler="org.apache.ibatis.type.OffsetDateTimeTypeHandler" />
        <typeHandler handler="org.apache.ibatis.type.OffsetTimeTypeHandler" />
        <typeHandler handler="org.apache.ibatis.type.ZonedDateTimeTypeHandler" />
    </typeHandlers>
</configuration>

Add in the configuration file in mybatis-config.xml

<TypeHandlers> nodes all content and add dependency maven

 <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-typehandlers-jsr310</artifactId>
      <version>1.0.2</version>
    </dependency>

 

Joda Time

JSR310 accompanied JDK8 release, it has brought new class time, date, type, date and time of the class, and a time stamp related classes.

I have dealt with the date and time of 7-8 time zones with Joda, joda ease. jsr310 suspected of plagiarism Joda time,

This is the time to win over users reluctant to give up java class treatment from certain procedures.

Before JDK8, if you've ever used Joda-time processing time, processing time can be added to entrust the following classes.

(No specific test)

maven dependence:

<dependency>
    <groupId>io.eliez</groupId>
    <artifactId>joda-time-mybatis</artifactId>
    <version>2.0.0</version>
</dependency>

mybatis-config.xml add the following code

<typeHandlers>
...
<typeHandler handler="org.joda.time.mybatis.handlers.DateTimeTypeHandler" />
        <typeHandler handler="org.joda.time.mybatis.handlers.LocalDateTypeHandler" />
        <typeHandler handler="org.joda.time.mybatis.handlers.LocalTimeTypeHandler" />
...
</typeHandlers>

 

Guess you like

Origin www.cnblogs.com/passedbylove/p/11388659.html