Question
Java Write a program that, given a month and year, prints a calendar, such as June 2016 Su Mo Tu We Th Fr Sa 1
Java
Write a program that, given a month and year, prints a calendar, such as
June 2016 Su Mo Tu We Th Fr Sa 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
To find out the weekday of the first day of the month, call:
int weekday = java.time.LocalDate.of(year, month, 1).getDayOfWeek().getValue();
// 1 = Monday, 2 = Tuesday, ..., 7 = Sunday To find out how many days in a month call the following including handling leap-year months, e.g. 2/29/2020, which will return 29:
LocalDate date = LocalDate.of(year, month, day); int lengthOfMonth = date.lengthOfMonth();
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started