亲测有效,无效我也不会浪费时间
public static Date getDateTimeOfDayBegin() throws ParseException {
return getDateTimeOfDayBegin(new Date());//调用下面的函数
}
public static Date getDateTimeOfDayBegin(Date date) throws ParseException {
SimpleDateFormat dateFormat1= new SimpleDateFormat("yyyy-MM-dd ");
String nowTime = dateFormat1.format(date).substring(0,10);
String startTime = nowTime +" 00:00:00"; //结束时间类似后面加 23:59:59
SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
Date DstartTime = dateFormat2.parse(startTime,pos);
return DstartTime;
}