Java Utility Library

Java Calendar - getMinimalDaysInFirstWeek() Method



The java.util.Calendar.getMinimalDaysInFirstWeek() method is used to get what the minimal days required in the first week of the year are; e.g., if the first week is defined as one that contains the first day of the first month of a year, this method returns 1. If the minimal days required must be a full week, this method returns 7.

Syntax

public int getMinimalDaysInFirstWeek()

Parameters

No parameter is required.

Return Value

Returns the minimal days required in the first week of the year.

Exception

NA.

Example:

In the example below, the java.util.Calendar.getMinimalDaysInFirstWeek() method returns the minimal days required in the first week of the year.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating Calendar objects
    Calendar Cal1 = Calendar.getInstance(Locale.US);
    Calendar Cal2 = Calendar.getInstance(Locale.FRANCE);

    //printing the first day of the week
    System.out.println("Minimum days required in US: " + 
                        Cal1.getMinimalDaysInFirstWeek());
    System.out.println("Minimum days required in FRANCE: " + 
                        Cal2.getMinimalDaysInFirstWeek());
  }
}

The output of the above code will be:

Minimum days required in US: 1
Minimum days required in FRANCE: 4

❮ Java.util - Calendar