* print Windows System calendar format * * 2016 April 16 Saturday 107 days of this year * * day one Two three four five six * 1 2 * 3 4 5 6 7 8 9 * 10 11 12 13 14 15 16 * 17 18 19 20 21 22 23 * 24 25 26 27 28 29 30 * * date class Calendar class dateformat Class simpledateformat class application and Practice * */ import Java.text.simpledateformat;public class myCalendar {public static void main (String[] args) {date d=new date (); Showmonth s=new showmonth (); Simpledateformat sdf=new simpledateformat ("yyyy mm month DD Day E year D Day"); System.out.println (Sdf.format (d)); System.out.println ("t \ t two \ \ Three \ Four \ five \ t six"); S.show ();}
Import java.util.calendar;public class showmonth { calendar c= Calendar.getinstance ();//Gets the maximum number of days per month int sumdays =c.getactualmaximum ( Calendar.date); public void show () { Set the current date to the first day (1st) c.set (calendar.day_of_month, 1); //get Current (1st) is the day of the Week int a = c.get (Calendar.day_of_week); //Print the space before the current (1st) Date for (int i=1; i<a; i++) { system.out.print ("\ T "); } //Print the date of each month for (int i=1;i<=sumdays;i++ ) { &nbsP System.out.print (i+ "\ t"); //if it is Saturday, newline output if (C.get (Calendar.day_of_week) ==calendar.saturday) { system.out.println (); } // increase the date by one day after each output date c.add (calendar.day_of_month, 1); } } }
Print the Windows System calendar format