mybatis + mysql +spring mvc date字段报错java.lang.NumberFormatException

<select id="findMapByCondition" resultType="java.util.HashMap">
        SELECT
        pc_user_id               as userId,
            username                 as username,
            password                 as password,
            email                    as email,
            cellphone                as cellphone,
            nickname                 as nickname,
            realname                 as realname,
            photo                    as photo,
            signature                as signature,
            lvl                      as lvl,
            experience               as experience,
            credits                  as credits,
           <!--  DATE_FORMAT(login_time , '%Y-%m-%d %H:%i')   as loginTime, -->
            CAST(login_time AS CHAR) AS loginTime,
            email_authentication     as emailAuthentication,
            cellphone_authentication as cellphoneAuthentication,
            realname_authentication  as realnameAuthentication,
            status                   as status,
            image_name               as imageName,
            image_path               as imagePath,
            expand_info_id           as expandInfoId,
            school_id                as schoolId,
            school_name              as schoolName,
            area_id                  as areaId,
            specialty_id             as specialtyId,
            specialty_name           as specialtyName,
            year_of_admission        as yearOfAdmission,
            year_of_graduate         as yearOfGraduate
        FROM view_user
        ${whereCondition}

    </select>


前提:model和数据库字段属性全为date

若使用

 DATE_FORMAT(login_time , '%Y-%m-%d %H:%i')   as loginTime, 

查询出来没问题,但是修改时,若会报

Caused by: java.lang.NumberFormatException: For input string: "2013-10-29 10:10",

若改成 CAST(login_time AS CHAR) AS loginTime,则解决问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值