zoukankan      html  css  js  c++  java
  • TIMESTAMP使用遇到得麻烦

    mysql按日期查询报空,怎么查看日志发现是14:36:01.709(Timestamp), 参数出了问题

    2018-04-17 14:36:16,887 [http-nio-8080-exec-5] DEBUG [cn.jbit.dao.OrderDao.addOrder] - ==> Preparing: INSERT INTO `order`(`uId`,`byTime`,`totalPrice`,`paymenttype`,`paymentState`) VALUES(?,?,?,?,?)
    2018-04-17 14:36:16,899 [http-nio-8080-exec-5] DEBUG [cn.jbit.dao.OrderDao.addOrder] - ==> Parameters: 2(Integer), 2018-04-17 14:36:01.709(Timestamp), 89.4(Double), 1(Integer), 1(Integer)
    2018-04-17 14:36:16,947 [http-nio-8080-exec-5] DEBUG [cn.jbit.dao.OrderDao.addOrder] - <== Updates: 1
    2018-04-17 14:36:58,135 [http-nio-8080-exec-5] DEBUG [cn.jbit.dao.OrderDao.searchByInfo] - ==> Preparing: SELECT * FROM `order` WHERE `uId`=? AND `byTime`=? AND `totalPrice`=?
    2018-04-17 14:36:58,139 [http-nio-8080-exec-5] DEBUG [cn.jbit.dao.OrderDao.searchByInfo] - ==> Parameters: 2(Integer), 2018-04-17 14:36:01.709(Timestamp), 89.4(Double)
    2018-04-17 14:36:58,154 [http-nio-8080-exec-5] DEBUG [cn.jbit.dao.OrderDao.searchByInfo] - <== Total: 0

    数据库数据如下,只保存到了秒

    无奈用了一下转换,以后会研究如何保存到毫秒

    DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String date= dateFormat2.format(order.getByTime());
    try {
    Date myDate2 =dateFormat2.parse(date);
    order.setByTime(myDate2);
    } catch (ParseException e) {
    e.printStackTrace();
    }
  • 相关阅读:
    day1-字符串拼接、表达式、break和continue
    ssh免密登录
    1-5 文档的基本 CRUD 与批量操作
    1-4 安装logstash
    1-3 安装cerebro
    1-2 kibana 7.5.1 安装配置
    1-1 elasticsearch7.5 集群搭建 es 7
    生产环境k8s集群搭建
    Gearman任务分布系统部署windows平台_使用Cygwin
    [转载]单元测试之道(使用NUnit)
  • 原文地址:https://www.cnblogs.com/zeussbook/p/8866475.html
Copyright © 2011-2022 走看看