hibernate 自动生成时间
- 作者: 多情的公子
- 来源: 51数据库
- 2021-01-26
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); user.setCreateTime(formatter.parse( formatter.format(new Date())));
手动格式化
你可以试试看用new simpledateformat("yyyy-mm-dd hh:mm:ss").format(begintime); 转换为string 然后用oracle本身的函数to_date("2008-11-11 11:11:11", "yyyy-mm-dd hh24:mi:ss"); string formatbgstring = new simpledateformat("yyyy-mm-dd hh:mm:ss").format(begintime); string formatendstring = new simpledateformat("yyyy-mm-dd hh:mm:ss").format(begintime); "and t.begintime > to_date('" + formatbgstring + "', 'yyyy-mm-dd hh24:mi:ss') and t.endtime < to_date('" + formatendstring + "', 'yyyy-mm-dd hh24:mi:ss')"
手动格式化
你可以试试看用new simpledateformat("yyyy-mm-dd hh:mm:ss").format(begintime); 转换为string 然后用oracle本身的函数to_date("2008-11-11 11:11:11", "yyyy-mm-dd hh24:mi:ss"); string formatbgstring = new simpledateformat("yyyy-mm-dd hh:mm:ss").format(begintime); string formatendstring = new simpledateformat("yyyy-mm-dd hh:mm:ss").format(begintime); "and t.begintime > to_date('" + formatbgstring + "', 'yyyy-mm-dd hh24:mi:ss') and t.endtime < to_date('" + formatendstring + "', 'yyyy-mm-dd hh24:mi:ss')"
推荐阅读
