oracle 时间类型 与java mybatis.xml 文件配置 resultMap 对应时间类型 JsonConfig 转换oracle里的时间类型

来源:互联网 发布:vivo清除所有数据密码 编辑:程序博客网 时间:2024/06/09 21:06

oracle:时间类型为 date    java  java..util.Date 类型


mybatis.xml  映射文件配置:resultMap 


<mapper namespace="ssmy.dao.SaleChanceDao">
<resultMap type="ssmy.dto.SaleChance" id="SaleChance">
 <!--<resultMap type="User" id="User"> 如果在sprin文件里配置初始化  mybatis里配置了别名就是有-->
        <!-- 用id属性来映射主键字段 -->
        <id property="id" column="id" jdbcType="INTEGER"/>
        <!-- 用result属性来映射非主键字段 -->
        <result property="chanceSource" column="chanceSource" jdbcType="VARCHAR"/>
        <result property="customerName" column="customerName" jdbcType="VARCHAR"/>
        <result property="cgjl" column="cgjl" jdbcType="INTEGER"/>
        <result property="overView" column="overView" jdbcType="VARCHAR"/>
        <result property="linkMan" column="linkMan" jdbcType="VARCHAR"/>
        <result property="linkPhone" column="linkPhone" jdbcType="VARCHAR"/> 
        <result property="description" column="description" jdbcType="VARCHAR"/>
        <result property="createMan" column="createMan" jdbcType="VARCHAR"/>
        <result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
        <result property="assignMan" column="assignMan" jdbcType="VARCHAR"/>
        <result property="assignTime" column="assignTime" jdbcType="TIMESTAMP"/>
        <result property="state" column="state" jdbcType="INTEGER"/> 
        <result property="devResult" column="devResult" jdbcType="INTEGER"/>   
    </resultMap>


JsonConfig 转换时间 oracle里查出的时间  date类型

                JSONObject result=new JSONObject();
JsonConfig jsonConfig=new JsonConfig();
jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor("yyyy-MM-dd HH:mm"));
JSONArray jsonArray=JSONArray.fromObject(list,jsonConfig);
result.put("rows", jsonArray);
result.put("total", total);
ResponseUtil.write(response, result);