| | |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.*; |
| | | import java.util.*; |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取指定月份开始时0点0分0秒 |
| | | * @param input 输入的时间,"yyyy-MM" |
| | | * @return |
| | | */ |
| | | public static Date getCurrentIdetMouthStart(String input) { |
| | | // 解析年月字符串 |
| | | YearMonth yearMonth = YearMonth.parse(input); |
| | | // 获取月份的开始时间(月初0点) |
| | | LocalDate startOfMonth = yearMonth.atDay(1); |
| | | LocalDateTime startDateTime = startOfMonth.atTime(LocalTime.MIN); |
| | | return Date.from(startDateTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | /** |
| | | * 获取当月结束时23点59分59秒 |
| | | * |
| | | * @return |
| | |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取指定月份结束时23点59分59秒 |
| | | * @param input 输入的时间,"yyyy-MM" |
| | | * @return |
| | | */ |
| | | public static Date getCurrentIdeaMouthEnd(String input) { |
| | | // 解析年月字符串 |
| | | YearMonth yearMonth = YearMonth.parse(input); |
| | | // 获取月份的结束时间(月末23:59:59秒) |
| | | LocalDate endOfMonth = yearMonth.atEndOfMonth(); |
| | | LocalDateTime endDateTime = endOfMonth.atTime(23, 59, 59); |
| | | return Date.from(endDateTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | /** |
| | | * 返回下月的这天 |
| | | * |