import java.time.DayOfWeek;
import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
LocalDate currentDate = LocalDate.now();
LocalDate startOfWeek = currentDate.with(DayOfWeek.MONDAY);
LocalDate startOfWeek = currentDate.with(DayOfWeek.SUNDAY);
System.out.println("当前周开始的时间:" + startOfWeek);
}
}
import java.time.LocalDate;
import java.time.YearMonth;
public class Main {
public static void main(String[] args) {
LocalDate currentDate = LocalDate.now();
YearMonth currentYearMonth = YearMonth.from(currentDate);
LocalDate startOfMonth = currentYearMonth.atDay(1);
LocalDate endOfMonth = currentYearMonth.atEndOfMonth();
System.out.println("当前月开始的时间:" + startOfMonth);
System.out.println("当前月结束的时间:" + endOfMonth);
}
}
import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
LocalDate currentDate = LocalDate.now();
int currentYear = currentDate.getYear();
LocalDate startOfYear = LocalDate.of(currentYear, 1, 1);
LocalDate endOfYear = LocalDate.of(currentYear, 12, 31);
System.out.println("当前年开始的时间:" + startOfYear);
System.out.println("当前年结束的时间:" + endOfYear);
}
}