获取一天的最大值和最小值

/**
* 获取一天的最大值和最小值
*
* @param dto
*/
private Map<String, Date> getDateMaxAndMin(BpmProcessQueryDTO dto) {
HashMap<String, Date> map = new HashMap<>();
Date applyDate = dto.getStartTime();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String applyDateStr = format.format(applyDate);
List<String> yearMonthDateList = StrUtil.split(applyDateStr, '-');
Calendar c = Calendar.getInstance();
c.set(Integer.valueOf(yearMonthDateList.get(0)), Integer.valueOf(yearMonthDateList.get(1)) - 1, Integer.valueOf(yearMonthDateList.get(2)));
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
Date applyDateMin = c.getTime();
c.set(Calendar.HOUR_OF_DAY, 23);
c.set(Calendar.MINUTE, 59);
c.set(Calendar.SECOND, 59);
c.set(Calendar.MILLISECOND, 999);
Date applyDateMax = c.getTime();

map.put("max", applyDateMax);
map.put("min", applyDateMin);
return map;
}
posted @ 2021-08-07 09:48  易不易  阅读(189)  评论(0编辑  收藏  举报