Calendar getFirstDayOfWeek() in Java

getFirstDayOfWeek(): This method is available in java.util.Calendar class of Java.

Syntax:

int java.util.Calendar.getFirstDayOfWeek()

This method gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.

Parameters: NA

Returns: the first day of the week.

Exceptions: NA

Approach

Java

import java.util.Calendar;

public class CalendargetFirstDayOfWeek {
    public static void main(String[] args) {

        // create a calendar
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, 2);

        System.out.println(calendar.getFirstDayOfWeek());
    }
}

Output:

1


No comments:

Post a Comment