java 获取本周周一0点和周日24点
时间: 2023-04-01 20:04:11 浏览: 244
你可以使用 Calendar 类来获取本周的周一和周日的时间。具体实现代码如下:
```java
import java.util.Calendar;
public class Main {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
calendar.set(Calendar.HOUR_OF_DAY, );
calendar.set(Calendar.MINUTE, );
calendar.set(Calendar.SECOND, );
calendar.set(Calendar.MILLISECOND, );
System.out.println("本周周一点:" + calendar.getTime());
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
System.out.println("本周周日24点:" + calendar.getTime());
}
}
```
输出结果如下:
```
本周周一点:Mon Sep 27 00:00:00 CST 2021
本周周日24点:Sun Oct 03 23:59:59 CST 2021
```
阅读全文