This post contains a total of 10+ Java Calendar Program Examples with Source Code. All these Calendar Programs are made using Java Language.
You can use the source code of these examples with credits to the original owner.
Related Posts
Java Calendar Programs
1. Calendar by Robert Sokolov
Made by Robert Sokolov. Source
Year 2022 ------Jan 2022------ M T W T F S S | | | | | | 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| |31| | | | | | | ------Feb 2022------ M T W T F S S | | 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| | | | | | | ....
/*
* Input the year you want to get a
* calendar for!
*/
public class Program {
public static void main(String[] args) {
java.util.Scanner in = new java.util.Scanner(System.in);
String input = in.nextLine();
Calendar c = new Calendar();
c.printYear(Integer.valueOf(input));
}
}
public class Calendar {
private static final Date exdat = new Date(30, 8, 2018);
private static final int exd = 3;
public static final MonthSett ms[] = new MonthSett[] {
new MonthSett("January", 31),
new MonthSett("February", 28),
new MonthSett("March", 31),
new MonthSett("April", 30),
new MonthSett("May", 31),
new MonthSett("June", 30),
new MonthSett("July", 31),
new MonthSett("August", 31),
new MonthSett("September", 30),
new MonthSett("October", 31),
new MonthSett("November", 30),
new MonthSett("December", 31)
};
public static final String days[] = new String[] {
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};
private Date curDate;
private int startDoW;
public Calendar(Date currentDate) {
curDate = currentDate;
}
public Calendar() {}
public void print(int month, int year) {
calcMonth(month, year);
StringBuilder sb = new StringBuilder();
int days = ms[month-1].getDays();
int cd = 1;
if(month == 2 && year % 4 == 0)
days++;
String mName = "";
String n = ms[month-1].getName().substring(0, 3) + " " + year;
int l = n.length();
for(int i = 0; i <= 7 * 3; i++) {
if(i >= 10 - l/2 && i <= 10 + l/2) {
mName += n;
i += l;
}
else {
mName += "-";
}
}
sb.append(mName + "\n");
sb.append(" ");
for(int i = 0; i < 7; i++) {
sb.append(this.days[i].substring(0, 1) + " ");
}
sb.append("\n");
int maxR = (int)Math.ceil((startDoW + days) / 7.0);
for(int r = 0; r < maxR; r++) {
for(int c = 0; c < 7; c++) {
String s = "";
s += "|";
if((c < startDoW && r == 0) || cd > days) {
sb.append(s + " ");
continue;
}
if(cd <= 9) {
s += " " + cd++;
}
else {
s += cd++;
}
sb.append(s);
}
sb.append("|");
sb.append("\n");
}
System.out.println(sb);
}
public void printYear(int year) {
if(year < Date.minYear) {
System.out.println("Minimum year is " + Date.minYear);
return;
}
System.out.println("Year " + year);
for(int i = 1; i <= 12; i++) {
System.out.println();
print(i, year);
}
}
public void calcMonth(int month, int year) {
Date date = new Date(1, month, year);
int tsd = date.getAsTimeStamp();
int tsx = exdat.getAsTimeStamp();
startDoW = roundDoW(exd + (tsd - tsx));
}
private static int roundDoW(int days) {
if(days > 6)
return roundDoW(days - 7);
else if(days < 0)
return roundDoW(days + 7);
return days;
}
}
public class Date {
public static final int minYear = 1960;
private int d, m, y;
public Date(int d, int m, int y) {
this.d = d;
this.m = m;
this.y = y;
}
public int getDay() {
return d;
}
public int getMonth() {
return m;
}
public int getYear() {
return y;
}
public int getAsTimeStamp() {
int D = d;
for(int i = 0; i < m-1; i++) {
D += Calendar.ms[i].getDays();
}
D += (y-1) * 365 + (int)((y - minYear) / 4.0);
if(y % 4 == 0) {
if(m > 2) {
D++;
}
}
return D;
}
public String toString() {
return zeropad(d, 2) + "." + zeropad(m, 2) + "." + y;
}
public static String zeropad(int n, int d) {
String z = "";
for(int i = 0; i < d; i++) {
if(d - i > String.valueOf(n).length()) {
z += "0";
}
else {
z += n;
return z;
}
}
return String.valueOf(n);
}
}
public class MonthSett {
private int d;
private String name;
public MonthSett(String name, int d) {
this.d = d;
this.name = name;
}
public int getDays() {
return d;
}
public String getName() {
return name;
}
}
2. Calendar of any year
Made by Bandhan Pramanik. Source
2000 January -------------------- S M T W T F S 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 31 February -------------------- S M T W T F S 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
/*
* What you will enter on the input console: Just enter the year(negatives for BCE)
* Note: Year 0 is invalid because after 1 BCE, there is 1 CE.
*/
import java.util.*;
class Calendar
{
int date[] [] = {{31, 31, 3, 4}, {28, 29, 28, 29}, {31, 31, 14, 14}, {30, 30, 4, 4}, {31, 31, 9, 9}, {30, 30, 6, 6}, {31, 31, 11, 11}, {31, 31, 8, 8}, {30, 30, 5, 5}, {31, 31, 10, 10}, {30, 30, 7, 7},{31, 31, 12, 12}};
String mon[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
int weekd = 0, month = 1, day = 1;
long year1 = 0, year = 0;
boolean isLeapYear = false;
void P()
{
int i;
System.out.println("=================================================================================================================================================");
System.out.print("\n\n\t\t\t\t\t\t\t\tCalendar " + Math.abs(year1));
if(year1 > 0)
System.out.println(" CE");
else
System.out.println(" BCE");
System.out.println("\n\n=================================================================================================================================================\n\n\n");
for(month = 1; month <= 12; month++)
{
System.out.println('\t' + (mon[(month - 1)]));
System.out.println("\t--------------------");
System.out.println("\tS M T W T F S");
System.out.print('\t');
for(i = 1; i <= weekd; i++)
System.out.print(" ");
day = 1;
if(isLeapYear)
{
while(day <= (date[(month - 1)] [1]))
{
System.out.print(day);
if(((int) (day / 10)) == 0)
System.out.print(" ");
else
System.out.print(" ");
weekd = (weekd + 1) % 7;
if(weekd == 0)
{
if(!(day == (date[(month - 1)] [1])))
{
System.out.println();
System.out.print('\t');
}
}
day++;
}
}
else
{
while(day <= (date[(month - 1)] [0]))
{
System.out.print(day);
if(((int) (day / 10)) == 0)
System.out.print(" ");
else
System.out.print(" ");
weekd = (weekd + 1) % 7;
if(weekd == 0)
{
if(!(day == (date[(month - 1)] [0])))
{
System.out.println();
System.out.print('\t');
}
}
day++;
}
}
System.out.println('\n');
}
}
void WeekdayDetermine()
{
int centuryc = 0, ccode = 0, a = 0, b = 0, c = 0, d = 0, dday = 0, ddigit = 0;
long century = 0;
if(year == 0)
{
System.out.println("Invalid year !!");
System.exit(0);
}
if(year < 0)
year += 1;
century = (long) (year / 100);
centuryc = (int) (century % 4);
ccode = (centuryc == 0) ? 2 : (centuryc == 1) ? 0 : (centuryc == 2) ? 5 : 3;
ddigit = (int) (year % 100);
if(ddigit == 0)
{
if(year % 400 == 0)
isLeapYear = true;
}
else
{
if(year % 4 == 0)
isLeapYear = true;
}
a = (int) (ddigit / 12);
b = ddigit % 12;
c = (int) (b / 4);
if(isLeapYear == true)
dday= date[(month - 1)] [3];
else
dday= date[(month - 1)] [2];
d = day - dday;
weekd = Math.abs((ccode + a + b + c + d) % 7);
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
Calendar obj = new Calendar();
obj.year1 = sc.nextLong();
obj.year = obj.year1;
System.out.println('\f');
obj.WeekdayDetermine();
obj.P();
}
}
3. Simple Date calendar
Made by Prince Raj. Source
Calendar has started : 23 Sep 2022 14:25:14 Sec
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
public class calendar implements Runnable {
@Override
public void run() {
for(;;){
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss");
Calendar c = new
GregorianCalendar();
System.out.println(sdf.format(c.getTime())+" Sec");
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
}
}
}
public class Program {
public static void main(String[] args) {
System.out.println("Calendar has started :");
calendar a = new calendar();
Thread t1 = new Thread(a);
t1.start();
}
}
4. Month Calendar Using Stepwise Refinement
Made by Chris. Source
2011 11 November 2011 --------------------------- Sun Mon Tue Wed Thu Fri Sat 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
// Sample Input: 2011(year) 11(Month of november)
// This program prints a month calendar given a year and an int representing the month using stepwise refinement
import java.util.Scanner;
public class Program
{
/** Main method */
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int year = input.nextInt();
int month = input.nextInt();
printMonth(year, month);
}
/** Print month method */
public static void printMonth(int year, int month) {
printMonthTitle(year, month);
printMonthBody(year, month);
}
/** Print month body method */
public static void printMonthBody(int year, int month) {
int startDay = getStartDay(year, month);
int daysInMonth = getNumberOfDaysInMonth(year, month);
int i = 0;
for(i = 0; i < startDay; i++) {
System.out.print(" ");
}
for (i = 1; i <= daysInMonth; i++) {
System.out.printf("%4d", i);
if ((i + startDay) % 7 == 0)
System.out.println();
}
System.out.println();
}
/** Print month title method */
public static void printMonthTitle(int year, int month) {
if (year < 1800 || month < 1 || month > 12) {
System.out.println("[ERROR] Enter a year greater than 1799 and a valid month (1 - 12)");
System.exit(1);
}
System.out.println(" " + getMonthName(month) + " " + year);
System.out.println(" ---------------------------");
System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
}
/** Get month name method */
public static String getMonthName(int month) {
String monthName = "";
switch(month) {
case 1 : monthName = "January"; break;
case 2 : monthName = "February"; break;
case 3 : monthName = "March"; break;
case 4 : monthName = "April"; break;
case 5 : monthName = "May"; break;
case 6 : monthName = "June"; break;
case 7 : monthName = "July"; break;
case 8 : monthName = "August"; break;
case 9 : monthName = "September"; break;
case 10 : monthName = "October"; break;
case 11 : monthName = "November"; break;
case 12 : monthName = "December"; break;
}
return monthName;
}
/** Get start day method */
public static int getStartDay(int year, int month) {
final int START_DAY_FOR_JAN_1_1800 = 3;
// Get total number of days from 1/1/1800 to month/1/year
int totalNumberOfDays = getTotalNumberOfDays(year, month);
// Return the start day for month/1/year
return (totalNumberOfDays + START_DAY_FOR_JAN_1_1800) % 7;
}
/** Get number of days in month method */
public static int getNumberOfDaysInMonth(int year, int month) {
if (month == 1 || month == 3 || month == 5 || month == 7 ||
month == 8 || month == 10 || month == 12)
return 31;
if (month == 4 || month == 6 || month == 9 || month == 11)
return 30;
if (month == 2) return isLeapYear(year) ? 29 : 28;
return 0; // if month is incorrect
}
/** Get total number of days method */
public static int getTotalNumberOfDays(int year,int month) {
int total = 0;
for (int i = 1800; i < year; i++) {
if (isLeapYear(i))
total += 366;
else
total += 365;
}
for (int i = 1; i < month; i++) {
total += getNumberOfDaysInMonth(year, i);
}
return total;
}
/** Compute if leap year */
public static boolean isLeapYear(int year) {
return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
}
}
5. Weekday calendar for any date
Made by Jorijn Sander. Source
1-1-2000 is a: Saturday
import java.util.Scanner;
/* Input in the format of:
dd
mm
yyyy
using this tool you can calculate the weekday for any date of any year*/
class MyClass {
public static void main(String[ ] args) {
Scanner day = new Scanner(System.in);
int dd = day.nextInt();
int mm = day.nextInt();
int yyyy = day.nextInt();
System.out.println(
dd+"-"+mm+"-"+yyyy+" is a: \r\n");
String [] weekday = {
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday",
};
dd+= yyyy;
int leapdays= 0;
if (mm>2){
leapdays=yyyy/4;
}else {
--yyyy;
leapdays=yyyy/4;
}
for(;mm>1;mm--) {
if (mm==2 || mm==4 || mm==6|| mm==8
|| mm==9 || mm==11) {
dd+=31;
}
if (mm== 5 || mm==7 || mm==10 ||
mm==12){
dd+=30;
}
if (mm== 3){
dd+=28;
}
}
dd+= 4;
dd+= leapdays;
while(dd>=7){
dd-=7;
};
String res = weekday[dd];
System.out.println(res);
}
}
6. Simple Java Calendar
Made by Digvijay Singh. Source
[Snoopy Picture] 2021 January February Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 1 2 3 4 5 6 3 4 5 6 7 8 9 7 8 9 10 11 12 13 10 11 12 13 14 15 16 14 15 16 17 18 19 20 17 18 19 20 21 22 23 21 22 23 24 25 26 27 24 25 26 27 28 29 30 28 31 March April Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 1 2 3 7 8 9 10 11 12 13 4 5 6 7 8 9 10 14 15 16 17 18 19 20 11 12 13 14 15 16 17 21 22 23 24 25 26 27 18 19 20 21 22 23 24 28 29 30 31 25 26 27 28 29 30 .....
import java.util.*;
import java.text.*;
class CalendarTask
{
public static void main(String args[]) throws Exception
{
printCalendar(2021, 2);
}
static void printCalendar(int year, int nCols)
{
if (nCols < 1 || nCols > 12)
throw new IllegalArgumentException("Illegal column width.");
Calendar date = new GregorianCalendar(year, 0, 1);
int nRows = (int) Math.ceil(12.0 / nCols);
int offs = date.get(Calendar.DAY_OF_WEEK) - 1;
int w = nCols * 24;
String[] monthNames = new DateFormatSymbols(Locale.US).getMonths();
String[][] mons = new String[12][8];
for (int m = 0; m < 12; m++)
{
String name = monthNames[m];
int len = 11 + name.length() / 2;
String format = MessageFormat.format("%{0}s%{1}s", len, 21 - len);
mons[m][0] = String.format(format, name, "");
mons[m][1] = " Su Mo Tu We Th Fr Sa";
int dim = date.getActualMaximum(Calendar.DAY_OF_MONTH);
for (int d = 1; d < 43; d++)
{
boolean isDay = d > offs && d <= offs + dim;
String entry = isDay ? String.format(" %2s", d - offs) : " ";
if (d % 7 == 1)
mons[m][2 + (d - 1) / 7] = entry;
else
mons[m][2 + (d - 1) / 7] += entry;
}
offs = (offs + dim) % 7;
date.add(Calendar.MONTH, 1);
}
System.out.printf("%" + (w / 2 + 10) + "s%n", "[Snoopy Picture]");
System.out.printf("%" + (w / 2 + 4) + "s%n%n", year);
for (int r = 0; r < nRows; r++)
{
for (int i = 0; i < 8; i++)
{
for (int c = r * nCols; c < (r + 1) * nCols && c < 12; c++)
{
System.out.printf(" %s", mons[c][i]);
}
System.out.println();
}
System.out.println();
}
}
}
7. Calendar Date
Made by Paweł Grünholz. Source
Mon Tue Wed Thu Fri Sat Sun 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
import java.time.*;
public class CalendarTest
{
public static void main(String[] args)
{
LocalDate date = LocalDate.now();
int month = date.getMonthValue();
int today = date.getDayOfMonth();
date = date.minusDays(today - 1);
DayOfWeek weekday = date.getDayOfWeek();
int value = weekday.getValue();
System.out.println(" Mon Tue Wed Thu Fri Sat Sun");
for (int i = 0; i < value; i++)
System.out.print(" ");
while (date.getMonthValue() == month)
{
System.out.printf("%3d", date.getDayOfMonth());
if (date.getDayOfMonth() == today)
System.out.print("*");
else
System.out.print(" ");
date = date.plusDays(1);
if (date.getDayOfWeek().getValue() == 1)
System.out.println();
}
if (date.getDayOfWeek().getValue() != 1)
System.out.println();
}
}
8. Days Calendar
Made by Amirshoh Abdusatorov. Source
Current date : 9-23-2022 date after one day : 9-24-2022 date before 10 days : 9-13-2022
import java.util.Calendar;
public class AddDaysToCurrentDate {
public static void main(String[] args) {
//create Calendar instance
Calendar now = Calendar.getInstance();
System.out.println(
"Current date : "
+ (now.get(Calendar.MONTH) + 1)
+ "-"
+ now.get(Calendar.DATE)
+ "-"
+ now.get(Calendar.YEAR));
//add days to current date using Calendar.add method
now.add(Calendar.DATE, 1);
System.out.println(
"date after one day : "
+ (now.get(Calendar.MONTH) + 1)
+ "-"
+ now.get(Calendar.DATE)
+ "-"
+ now.get(Calendar.YEAR));
//substract days from current date using Calendar.add method
now = Calendar.getInstance();
now.add(Calendar.DATE, -10);
System.out.println(
"date before 10 days : "
+ (now.get(Calendar.MONTH) + 1)
+ "-"
+ now.get(Calendar.DATE)
+ "-"
+ now.get(Calendar.YEAR));
}
}
9. calendar test
Made by Nitin Alreja. Source
Calendar test Day: 2022/09/23 Day + 1 month: 2022/10/23 Day: 2022/01/27 Day + 1 month: 2022/02/27 Day: 2022/01/28 Day + 1 month: 2022/02/28 Day: 2022/01/29 Day + 1 month: 2022/02/28 Day: 2022/01/30 Day + 1 month: 2022/02/28 Day: 2022/01/31 Day + 1 month: 2022/02/28
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
class Playground {
public static void main(String[ ] args) {
System.out.println("Calendar test");
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
// Assume it today
Calendar cal = Calendar.getInstance();
System.out.println("Day: " + dateFormat.format(cal.getTime()));
cal.add(Calendar.MONTH, 1);
System.out.println("Day + 1 month: " + dateFormat.format(cal.getTime()));
System.out.println("");
// Assume its jan 27th, what does +1 month mean?
cal.set(Calendar.MONTH, 0);
cal.set(Calendar.DAY_OF_MONTH, 27);
System.out.println("Day: " + dateFormat.format(cal.getTime()));
cal.add(Calendar.MONTH, 1);
System.out.println("Day + 1 month: " + dateFormat.format(cal.getTime()));
System.out.println("");
// Assume its jan 28th, what does +1 month mean?
cal.set(Calendar.MONTH, 0);
cal.set(Calendar.DAY_OF_MONTH, 28);
System.out.println("Day: " + dateFormat.format(cal.getTime()));
cal.add(Calendar.MONTH, 1);
System.out.println("Day + 1 month: " + dateFormat.format(cal.getTime()));
System.out.println("");
// Assume its jan 29th, what does +1 month mean?
cal.set(Calendar.MONTH, 0);
cal.set(Calendar.DAY_OF_MONTH, 29);
System.out.println("Day: " + dateFormat.format(cal.getTime()));
cal.add(Calendar.MONTH, 1);
System.out.println("Day + 1 month: " + dateFormat.format(cal.getTime()));
System.out.println("");
// Assume its jan 30th, what does +1 month mean?
cal.set(Calendar.MONTH, 0);
cal.set(Calendar.DAY_OF_MONTH, 30);
System.out.println("Day: " + dateFormat.format(cal.getTime()));
cal.add(Calendar.MONTH, 1);
System.out.println("Day + 1 month: " + dateFormat.format(cal.getTime()));
System.out.println("");
// Assume its jan 31st, what does +1 month mean?
cal.set(Calendar.MONTH, 0);
cal.set(Calendar.DAY_OF_MONTH, 31);
System.out.println("Day: " + dateFormat.format(cal.getTime()));
cal.add(Calendar.MONTH, 1);
System.out.println("Day + 1 month: " + dateFormat.format(cal.getTime()));
System.out.println("");
}
}
10. FULL MOON Calendar
Made by Gratuity Tucci. Source
Full Moon on : Wed Sep 06 11:41:36 GMT 2017 Full Moon on : Fri Oct 06 00:10:24 GMT 2017 Full Moon on : Sat Nov 04 12:39:12 GMT 2017 Full Moon on : Mon Dec 04 01:08:00 GMT 2017 Full Moon on : Tue Jan 02 13:36:48 GMT 2018 ....
import java.util.*;
import static java.lang.System.out;
class FullMoons {
static int DAY_IM = 1000 * 60 * 60 * 24;
public static void main(String[] args) {
Calendar c = Calendar.getInstance(); //the results of the calendar methods and held in this variable
c.set(2017, 7, 7, 23, 12); //set time to Aug 7, 2017 at 11:12
//month is zero-based 7 = August, 0 = January
//TimeZone()
long day1 = c.getTimeInMillis();
for (int x = 0; x < 60; x++) {
day1 += (DAY_IM * 29.52);
c.setTimeInMillis(day1);
out.println(String.format("Full Moon on : %tc", c)); //calendar instance is formated as a String and printed out
}
}
}
11. Calendar by Malhar Mujumdar
Made by Malhar Mujumdar. Source
Enter the year which you would like to see January 2000 _____________________________________ Sun Mon Tue Wed Thu Fri Sat 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 31 February 2000 _____________________________________ Sun Mon Tue Wed Thu Fri Sat 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 ...
import java.util.*;
public class ICSE10Project
{
public static void main(String[] args) {
Scanner v =new Scanner(System.in);
int k=0; int z;
int y;
System.out.println("Enter the year which you would like to see");
y = v.nextInt(); int j=y;
int m=1;
int d=1;
int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
//Sakamoto Algorithm
y -= m < 3? m:0;
int Dayofweek=( y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
if(Dayofweek==0)
k=1;
int startDayOfMonth = Dayofweek;
int spaces = startDayOfMonth;
// months[i] = name of month i
String[] months = {
"", // leave empty so that we start with months[1] = "January"
"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"
};
// days[i] = number of days in month i
int[] days = {
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
for (int M = 1; M <= 12; M++) {
// check for leap year
if ((((j% 4 == 0) && (j % 100 != 0)) || (j % 400 == 0)) && M == 2)
days[M] = 29;
// print calendar header
// Display the month and year n h
System.out.println(" "+ months[M] + " " + j);
// Display the lines
System.out.println("_____________________________________");
System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
// spaces required
spaces = (days[M-1] + spaces)%7;
// print the calendar
for (int i = 0; i < spaces; i++)
System.out.print(" ");
for (int i = 1; i <= days[M]; i++) {
System.out.printf(" %3d ", i);
if (((i + spaces) % 7 == 0) || (i == days[M])) System.out.println();
}
System.out.println();
}
if(k==1&&j%4!=0)
System.out.println("The number of sundays in the year is 53");
System.out.println("the Number of fixed holidays is 53 ");
if(k==1&&j%4==0)
System.out.println("The number of sundays in the year is 53");
System.out.println("the Number of fixed holidays is 53 ");
if(k==0)
System.out.println("The number of sundays in the year is 52");
System.out.println("The Number of fixed holidays is 52");
System.out.println( "The list of Leap years until 2100");
for( z=2000;z<2100;z=+4);
{ System.out.println( z);}
} }