The Java date class and the Calendar class have a print date applet that can be used directly.
PackageCom.boy.Idate.calendar;ImportJava.text.ParseException;ImportJava.text.SimpleDateFormat;ImportJava.util.Calendar;ImportJava.util.Date;/*** Console Visualization Calendar *@authorOkuda*/PublicClassVisualcalendar {PublicStaticvoidMain (string[] args) {System.out.println ("t \ t two \ t three \ Four \ five \ t six");//Convert string to date and then convert to Calendar standard Date class Calendar c =Calendar.getinstance (); C.settime (Strtodate ("2016-3-12")) );//Gets the day of the one month.int monthday =C.get (calendar.date);//Turn the input date into the month of 1th C.set (calendar.date, 1);//Gets the total number of days for all the month based on the month of the monthint monthallday =C.getactualmaximum (Calendar.day_of_month);//Get the number of weeks of the dayint DayOfWeek =C.get (Calendar.day_of_week);//Control the printing of the first space character based on the number of weeks of the month 1th (if it is Tuesday, empty one block)for (int i = 0; i < dayOfWeek-1; i++) {System.out.print ("\ t"); }//Cycle Days of the monthfor (int i = 1; I <=monthAllDay; i++) {if (i = =MonthDay) {System.out.print ("-"); } System.out.print (i+ "\ T");int w =C.get (Calendar.day_of_week);//2. Change of line every Saturdayif (w==Calendar.saturday) {System.out.println ();}//3. Day of the month plus 1 days c.add (calendar.date, 1public static Date Strtodate (String source) {SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd" Span style= "color: #000000;" >); try {return Sdf.parse (source); } catch (ParseException e) { // TODO auto-generated catch Block E.printstacktrace (); } return null
Applet for a console printing date for the Java date class and the Calendar class