📄 dated.java
字号:
/**
* 生成日历程序(界面)
* */
package com.lianjiping.demoa;
import java.util.*;
public class DateD {
public static void main(String[] args) {
GregorianCalendar dc = new GregorianCalendar();
int today = dc.get(Calendar.DAY_OF_MONTH);
int month = dc.get(Calendar.MONTH);
dc.set(Calendar.DAY_OF_MONTH, 1);
int weekday = dc.get(Calendar.DAY_OF_WEEK);
System.out.println("sun mon tue wed thu fri liu");
for (int i = Calendar.SUNDAY; i < weekday; i++)
System.out.print("");
do {
int day = dc.get(Calendar.DAY_OF_MONTH);
if (day == 1 && weekday != 7) {
for (int x = 0; x < 4 * (weekday - 1); x++) {
System.out.print(" ");
}
}
if (day < 10)
System.out.print(" ");
System.out.print(day);
if (day == today)
System.out.print("* ");
else
System.out.print(" ");
if (weekday == Calendar.SATURDAY)
System.out.println();
dc.add(Calendar.DAY_OF_MONTH, 1);
weekday = dc.get(Calendar.DAY_OF_WEEK);
} while (dc.get(Calendar.MONTH) == month);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -