- 获得某天最大时间
public static Date getEndOfDay(Date date) {
if (date == null) {date = new Date();}
return DateUtil.endOfDay(date); // 2023-05-23 23:59:59
}
- 获取某天最小时间
public static Date getBeginOfDay(Date date) {
if (date == null) {date = new Date();}
return DateUtil.beginOfDay(date); // 2023-05-23 00:00:00
}
- 获取下一个月日期
public static final String getNextMonth(String queryMonth) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
Calendar calendar = Calendar.getInstance();
// 设置为当前时间
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
Date month = dateFormat.parse(queryMonth);
calendar.setTime(month);
calendar.add(Calendar.MONTH,1);
Date date = calendar.getTime();
return format.format(date);
}