使用Java8新特性LocalDateTime获取周几
package test;
import java.time.LocalDateTime;
public class Test {
public static void main(String[] args){
//获取当前时间
LocalDateTime endDate = LocalDateTime.now();
//获取当前周
Integer week = endDate.getDayOfWeek().getValue();
System.out.println("获取当前周:" + week);
}
}
控制台执行结果: