public static void main(String[] args) {
LocalDate localDate = LocalDate.of(2024, 4, 22);
int currentWeek = getWeekOfMonth(localDate);
String result = calNextWeek(localDate);
System.out.println(result);
}
public static int getWeekOfMonth(LocalDate localDate) {
return localDate.get(WeekFields.of(Locale.getDefault()).weekOfMonth());
}
public static LocalDate getNextWeek(LocalDate localDate) {
return localDate.plusWeeks(1);
}
public static String calNextWeek(LocalDate currentDate) {
LocalDate nextWeekDate = getNextWeek(currentDate);
int nextWeekOfMonth = getWeekOfMonth(nextWeekDate);
Month month = nextWeekDate.getMonth();
return String.format("%d月%d周", month.getValue(), nextWeekOfMonth);
}
计算下周是几月第几周
于 2024-05-06 22:31:13 首次发布