Java时间类LocalDate的小应用: 自制时间日历
鄙人愚钝 ,最后一行不知道那里是什么意思,有什么体现
代码:
package fourthChapter;
import java.time.DayOfWeek;
import java.time.LocalDate;
/**
- 2019年7月1日15:42:52
- @author 董
*/
public class CalendarTest {
public static void main(String[] args) {
LocalDate dzytoday = LocalDate.now();
LocalDate date = dzytoday.plusDays(34);
// LocalDate date = LocalDate.now();
int month = date.getMonthValue();//当前月份
int today = date.getDayOfMonth();//当前日期
System.out.println(date);
date = date.minusDays(today-1);
System.out.println(date);
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() == today)
System.out.print("*");
else
System.out.print(" ");
date = date.plusDays(1);
if(date.getDayOfWeek().getValue() == 1)System.out.println();
}
//这一句代码是什么意思?有点不懂
if(date.getDayOfWeek().getValue() != 1 )System.out.println();
}
}