e375. determining the number of days in a month.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 12 行

TXT
12
字号
This example uses the Calendar class to determine the number of days in the month of a particular year. 
    // Create a calendar object of the desired month
    Calendar cal = new GregorianCalendar(1999, Calendar.FEBRUARY, 1);
    
    // Get the number of days in that month
    int days = cal.getActualMaximum(Calendar.DAY_OF_MONTH); // 28
    
    // Try month in a leap year
    cal = new GregorianCalendar(2000, Calendar.FEBRUARY, 1);
    days = cal.getActualMaximum(Calendar.DAY_OF_MONTH);     // 29

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?