java.time.DayOfWeek.getValue() Method Example



Description

The java.time.DayOfWeek.getValue() method gets the day-of-week int value.

Declaration

Following is the declaration for java.time.DayOfWeek.getValue() method.

public int getValue()

Return Value

the day-of-week, from 1 (Monday) to 7 (Sunday).

Example

The following example shows the usage of java.time.DayOfWeek.getValue() method.

package com.tutorialspoint;

import java.time.DayOfWeek;

public class DayOfWeekDemo {
   public static void main(String[] args) {
 
      DayOfWeek day = DayOfWeek.of(3);
      System.out.println(day.getValue());  
   }
}

Let us compile and run the above program, this will produce the following result −

3
Advertisements