Java Console Simple Calendar view

Source: Internet
Author: User

First on the code:

Importconnection. Firstpanel;ImportJava.util.Calendar;Importjava.util.Date;ImportJava.util.Scanner;//Why use the date class? Because the Calendar class internationalization standard Public classMain { Public Static voidMain (string[] args) {Scanner sc=NewScanner (system.in); String[] 中文版= {"One", "two", "three", "four", "five", "six", "Day"}; String[] Month= {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December",};  while(Sc.hasnext ()) {intCC = 0; intYear =Sc.nextint (); Calendar Calendar=calendar.getinstance ();  for(inti = 0; I <12;i++) {System.out.println (month[cc++]);  for(intj = 0; J <english.length;j++) {System.out.printf ("%3s", English[j]);                } System.out.println ();                Calendar.clear ();                Calendar.set (calendar.year,year);                Calendar.set (Calendar.month,i); intMonth_days =Calendar.getactualmaximum (Calendar.day_of_month); intFirst_day = Calendar.get (calendar.day_of_week)-1; intN =0; if(first_day>0){                 for(intK = 2; K<=first_day; k++) {n= First_day-1; System.out.printf ("%4s", "" "); }                }                if(first_day==0) {n= 6;  for(intK = 1; k< 7; k++) {System.out.printf ("%4s", "" "); }                }                 for(intk = 1; k<=month_days;k++) {System.out.printf ("%3d", K); N++; if(n%7==0) {System.out.println ();                }} System.out.println (); }            }        }    }

Some example methods are given using Java.util.Calendar in Java and (Internationalized standard date Class).

Java Console Simple Calendar view

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.