Saturday, February 7, 2026
HomeLanguagesJavaWeekFields getMinimalDaysInFirstWeek() method in Java with Examples

WeekFields getMinimalDaysInFirstWeek() method in Java with Examples

The getMinimalDaysInFirstWeek() method of WeekFields class is used to return the minimal number of days in the first week of a month or year. For example, the ISO-8601 requires 4 days (more than half a week) to be present before counting the first week. This method returns the minimal number of days in the first week of a month or year, from 1 to 7.

Syntax:

public int getMinimalDaysInFirstWeek()

Parameters: This method accepts nothing.

Return value: This method returns the minimal number of days in the first week of a month or year, from 1 to 7.

Below programs illustrate the WeekFields.getMinimalDaysInFirstWeek() method:
Program 1:




// Java program to demonstrate
// WeekFields.getMinimalDaysInFirstWeek() method
  
import java.time.DayOfWeek;
import java.time.temporal.WeekFields;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // create WeekFields
        WeekFields weekFields
            = WeekFields.of(DayOfWeek.SATURDAY, 2);
  
        // apply getMinimalDaysInFirstWeek()
        int noOfDays
            = weekFields.getMinimalDaysInFirstWeek();
  
        // print results
        System.out.println("Minimal number of days"
                           + " in the first week: "
                           + noOfDays);
    }
}


Output:

Minimal number of days in the first week: 2

Program 2:




// Java program to demonstrate
// WeekFields.getMinimalDaysInFirstWeek() method
  
import java.time.temporal.WeekFields;
import java.util.Locale;
  
public class GFG {
    public static void main(String[] args)
    {
  
        Locale locale = new Locale("EN", "INDIA");
  
        // create WeekFields
        WeekFields weekFields
            = WeekFields.of(locale);
  
        // apply getMinimalDaysInFirstWeek()
        int noOfDays
            = weekFields.getMinimalDaysInFirstWeek();
  
        // print results
        System.out.println("Minimal number of days"
                           + " in the first week: "
                           + noOfDays);
    }
}


Output:

Minimal number of days in the first week: 1

References: https://docs.oracle.com/javase/10/docs/api/java/time/temporal/WeekFields.html#getMinimalDaysInFirstWeek()

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

3 COMMENTS

Most Popular

Dominic
32491 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6862 POSTS0 COMMENTS
Nicole Veronica
11987 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12075 POSTS0 COMMENTS
Shaida Kate Naidoo
6996 POSTS0 COMMENTS
Ted Musemwa
7237 POSTS0 COMMENTS
Thapelo Manthata
6947 POSTS0 COMMENTS
Umr Jansen
6933 POSTS0 COMMENTS