Java 日历 getMinimalDaysInFirstWeek()方法及示例

Java 日历 getMinimalDaysInFirstWeek()方法及示例

Calendar类中的 getMinimalDaysInFirstWeek() 方法用于返回所需年份第一周的最小天数。

语法:

public int getMinimalDaysInFirstWeek()

参数: 该方法不接受任何参数。
返回值: 该方法返回下一年第一周所需的最小天数。
以下程序说明了日历类的getMinimalDaysInFirstWeek()方法的工作情况:

例子1:

// Java code to illustrate
// getMinimalDaysInFirstWeek() method
 
import java.util.*;
 
public class Calendar_Demo {
    public static void main(String args[])
    {
 
        // Creating a calendar
        Calendar calndr
            = new GregorianCalendar(2018, 6, 10);
 
        // Getting the required minimal days
        int min_days
            = calndr.getMinimalDaysInFirstWeek();
 
        // Displaying the results
        System.out.println("The Minimal"
                           + " days required: "
                           + min_days);
    }
}

输出

The Minimal days required: 1

例2:

// Java code to illustrate
// getMinimalDaysInFirstWeek() method
 
import java.util.*;
 
public class Calendar_Demo {
    public static void main(String args[])
    {
 
        // Creating a calendar
        Calendar calndr = Calendar.getInstance();
 
        // Getting the required minimal days
        int min_days
            = calndr.getMinimalDaysInFirstWeek();
 
        // Displaying the results
        System.out.println("The Minimal"
                           + " days required: "
                           + min_days);
    }
}

输出

The Minimal days required: 1

参考资料: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#getMinimalDaysInFirstWeek-

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

Java 日历