public static String getCurrentTerm() {
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 确定当前学年学期的起始和结束时间
int year = now.getYear();
LocalDateTime autumnStart = LocalDateTime.of(year, 9, 1, 0, 0);
LocalDateTime springStart = LocalDateTime.of(year, 2, 1, 0, 0);
// 计算当前学年学期
if (now.isBefore(springStart)) {
return (year - 1) + "-" + year + "-1";
} else if (now.isAfter(autumnStart)) {
return year + "-" + (year + 1) + "-1";
} else {
return (year - 1) + "-" + year + "-2";
}
}
将当前时间转换成学年学期工具类
最新推荐文章于 2024-07-29 14:22:26 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)