数据库是Date类型。实体类里是String类型。用的hibernatedaosupport的save()方法保存到oracle数据库,
已经用simpledateformat转换过了
// SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
// email.setSendTime(sf.format(new Date()));但还是报错啊
literal does not match format string

解决方案 »

  1.   

    格式错了吧.
    YYYY-MM-DD HH:MI:SS
      

  2.   


    你这格式才是错的啊java.lang.IllegalArgumentException: Illegal pattern character 'Y'
      

  3.   

    哎呀,悲剧了!兄弟抱歉了,没看仔细!
    我这是to_date转换时候用的!
      

  4.   

    //如果你的格式是字符串
    SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    String strDateTime = "2010-09-21 15:30:21";
    email.setSendTime(sf.parse(strDateTime));
    //如果直接获取的当前时间
    email.setSendTime(new java.util.Date());