public String DateToStringBeginOrEnd(Date date,Boolean flag) {
String time = null;
SimpleDateFormat dateformat1 = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Calendar calendar1 = Calendar.getInstance();
//获取某一天的0点0分0秒 或者 23点59分59秒
if (flag) {
calendar1.setTime(date);
calendar1.set(calendar1.get(Calendar.YEAR), calendar1.get(Calendar.MONTH), calendar1.get(Calendar.DAY_OF_MONTH),
0, 0, 0);
Date beginOfDate = calendar1.getTime();
time = dateformat1.format(beginOfDate);
System.out.println(time);
}else{
Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(date);
calendar1.set(calendar2.get(Calendar.YEAR), calendar2.get(Calendar.MONTH), calendar2.get(Calendar.DAY_OF_MONTH),
23, 59, 59);
Date endOfDate = calendar1.getTime();
time = dateformat1.format(endOfDate);
System.out.println(time);
}
return time;
}