```package com.msb; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Scanner; import java.util.SimpleTimeZone; public class CalendarDemo { public static void main(String[] args) throws ParseException { //键盘输入日历 Scanner scanner=new Scanner(System.in); String s=scanner.next(); SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd"); Date date = simpleDateFormat.parse(s); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int actualMaximum = calendar.getActualMaximum(Calendar.DATE); //获取当天的是哪天 int i1 = calendar.get(Calendar.DATE); calendar.set(Calendar.DATE,1); int week = calendar.get(Calendar.DAY_OF_WEEK); //System.out.println(i); System.out.println("日t一t二t三t四t五t六t"); int num=week-1; int count=0; for (int i = 1; i <=num ; i++) { System.out.print("t"); count++; } for (int i = 1; i <=actualMaximum ; i++) { if (i==i1){ System.out.print(i+"*"+"t"); }else { System.out.print(i+"t"); } count++; if (count%7==0){ System.out.println(); } } } }
不懂得话可以随时私信,上面的代码亲测是没有问题的
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)