import java
.time
.DayOfWeek
;
import java
.time
.LocalDate
;
public class Demo02 {
public static void main(String
[] args
) {
LocalDate date
= LocalDate
.now();
int month
= date
.getMonthValue();
int day
= date
.getDayOfMonth();
date
= date
.minusDays(day
- 1);
DayOfWeek weekday
= date
.getDayOfWeek();
int value
= weekday
.getValue();
System
.out
.println("Mon Tue Wed Thu Fri Sat Sun");
for (int i
= 1; i
< value
; i
++) {
System
.out
.print(" ");
}
while (date
.getMonthValue() == month
) {
System
.out
.printf("%3d",date
.getDayOfMonth());
if(date
.getDayOfMonth() == day
) {
System
.out
.print("*");
} else {
System
.out
.print(" ");
}
date
= date
.plusDays(1);
if(date
.getDayOfWeek().getValue() == 1) {
System
.out
.println();
}
}
}
}
转载请注明原文地址:https://tech.qufami.com/read-18740.html