| | |
| | | // System.out.println(DateUtil.afterMinutesDate(-5)); |
| | | |
| | | |
| | | List<Date> list =getThisMonthDateList(); |
| | | for(Date d :list){ |
| | | System.out.println(getPlusTime2(d)); |
| | | } |
| | | List<Date> list1 =getThisYearMonthList(); |
| | | for(Date d :list1){ |
| | | System.out.println(getPlusTime2(d)); |
| | | } |
| | | System.out.println(DateUtil.getBeforMonthStr(new Date(),1)); |
| | | System.out.println(DateUtil.getBeforMonthStr(new Date(),12)); |
| | | |
| | | // List<Date> list =getThisMonthDateList(); |
| | | // for(Date d :list){ |
| | | // System.out.println(getPlusTime2(d)); |
| | | // } |
| | | // List<Date> list1 =getThisYearMonthList(); |
| | | // for(Date d :list1){ |
| | | // System.out.println(getPlusTime2(d)); |
| | | // } |
| | | |
| | | // Date startTime = DateUtil.StringToDate("2024-05-01 08:00:00" ,"yyyy-MM-dd HH:mm:ss"); |
| | | // Date endTime = DateUtil.StringToDate("2024-05-01 17:00:00" ,"yyyy-MM-dd HH:mm:ss"); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取X天后的日期 |
| | | * @param date |
| | | * @param beforMonths 下月 -1 上月 1 |
| | | * @return |
| | | */ |
| | | public static String getBeforMonthStr(Date date,Integer beforMonths){ |
| | | ZonedDateTime zonedDateTime = date.toInstant().atZone(ZoneId.systemDefault()); |
| | | // 转换为java.time.LocalDate,计算x天的日期 |
| | | LocalDate dateBeforeDay = zonedDateTime.toLocalDate().minusMonths(beforMonths); |
| | | return dateBeforeDay.toString(); |
| | | } |
| | | |
| | | } |