学习|Calendar 设置某年某月的日历

package day5; import java.util.Calendar; import java.util.Scanner; public class date { public static void main(String[] args) { System.out.println("输入年"); String weet[]={"星期7","星期1","星期2","星期3","星期4","星期5","星期6"}; Scanner a=new Scanner(System.in); Calendar cal=Calendar.getInstance(); int year=a.nextInt(); cal.set(Calendar.YEAR, year); //设置年 System.out.println("输入月"); int yue=a.nextInt(); cal.set(Calendar.MONTH, yue-1); //设置月,月设置要-1 System.out.println("输入日"); int day=a.nextInt(); cal.set(Calendar.DATE, day); //设置月 for (int i = 0; i < weet.length; i++) { System.out.print(weet[i]+"\t"); } int days=cal.getActualMaximum(Calendar.DATE); //计算出该月有多少天 cal.set(Calendar.DATE, 1); //设置为该月的第一天 int one=cal.get(Calendar.DAY_OF_WEEK)-1; //获取该月第一天为星期几;one为每月前空日期的个数 for (int i = 0; i

【学习|Calendar 设置某年某月的日历】学习|Calendar 设置某年某月的日历
文章图片

    推荐阅读