查询距离当前时间5分钟的数据

来源:互联网 发布:宾馆网络电视怎么打开 编辑:程序博客网 时间:2024/06/05 02:55

查询距离当前时间5分钟的数据

最近在做项目的过程中,需要用定时任务查询最近一段时间内数据库更新的数据:

SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");TestBean bean=new TestBean();Date date= new Date();String startTime=sdf.format(date);                      //系统当前时间String endTime=sdf.format(date.getTime()-1000*60*5);    //当前时间前五分钟bean.setStartTime(startTime);bean.setEndTime(endTime);//查询距离当前时间五分钟内的数据list=volcanicDao.selectLog(bean);//SQL语句:本人用的oracle数据库select * from TE201 twhere t.update_time between to_date(#{endTime},'yyyy-mm-dd hh24:mi:ss') and to_date(#{startTime},'yyyy-mm-dd hh24:mi:ss')order by t.update_time desc
0 0
原创粉丝点击