Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Java outputs calendar codes for specified years and months based on the Calendar class.

2026-02-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article shows you Java based on the Calendar class output calendar code for the specified year and month how to write, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article, I hope you can get something.

The code is as follows

Package com.cyl.test3; import java.util.Calendar;import java.util.Scanner; public class RiLi {public static void main (String [] args) {int year= 2020; int month= 2; Calendar calendar = Calendar.getInstance (); / / since the month in Java starts counting from October, the real month December (month=12) needs to be subtracted by 1 to be December calendar.set (year,month-1,1) in Java; / / the first day of each month int weekday = calendar.get (Calendar.DAY_OF_WEEK)-1 System.out.println ("the first day of the month" + weekday); int maxDay = calendar.getActualMaximum (Calendar.DAY_OF_MONTH); System.out.println ("maximum days of the month" + maxDay); System.out.println ("\ t\ t" + year+ "year" + month+ "month"); System.out.println ("1\ t 2\ t 3\ t 4\ t 5\ t 6\ t day\ t"); int temp = 0; / / fill in the blanks for (int I = 0; I < weekday-1 For +) {System.out.print ("\ t"); temp++;} for (int I = 1; I

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

  • How to judge browsers by conditional comments

    This article focuses on "how to use conditional comments to judge browsers". Interested friends may wish to take a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use conditional comments to judge browsers!

    12
    Report