按时间检索中,开始时间为00:00:00,结束时间为23:59:59

来源:互联网 发布:自制手机直播软件 编辑:程序博客网 时间:2024/06/05 01:55

项目中需要利用开始时间和结束时间来检索数据,如果没检索时间没有精确到秒,仅仅是按照年月日(yyyy-MM-dd)来检索的话,向后台发送的时间节点都会是当天的00:00:00,会导致检索出的数据与预想的不一样。可已将开始时间和结束时间进行一个格式化,然后再调用。

   publicstatic Date getStartTimeOfDate(DatecurrentDate) {

     Assert.notNull(currentDate);

     String strDateTime =date2String(currentDate,"yyyy-MM-dd") +"00:00:00";

     returnstring2Date(strDateTime,"yyyy-MM-dd hh:mm:ss");

   }

  

   publicstatic Date getEndTimeOfDate(DatecurrentDate) {

     Assert.notNull(currentDate);

     String strDateTime =date2String(currentDate,"yyyy-MM-dd") +"23:59:59";

     returnstring2Date(strDateTime,"yyyy-MM-dd hh:mm:ss");

   }

通过调用getStartTimeOfDategetEndTimeOfDate来进行开始时间和结束时间的格式化。


类包下载地址:http://download.csdn.net/download/hgjacky/9954801。

阅读全文
1 0
原创粉丝点击