//获取0点
public static Date getStartTime() {Calendar todayStart = Calendar.getInstance();todayStart.set(Calendar.HOUR_OF_DAY, 0);todayStart.set(Calendar.MINUTE, 0);todayStart.set(Calendar.SECOND, 0);todayStart.set(Calendar.MILLISECOND, 0);return todayStart.getTime();}
//获取23点
public static Date getnowEndTime() {Calendar todayEnd = Calendar.getInstance();todayEnd.set(Calendar.HOUR_OF_DAY, 23);todayEnd.set(Calendar.MINUTE, 59);todayEnd.set(Calendar.SECOND, 59);todayEnd.set(Calendar.MILLISECOND, 999);return todayEnd.getTime();}
博客中有一篇帖子也是获取当日的起始时间和结束时间的,但是写法错误,特发布正确的写法