Java Date Time - Month maxLength() example








Month maxLength() gets the maximum length of this month in days.

Syntax

maxLength has the following syntax.

public int maxLength()

Example

The following example shows how to use maxLength.

import java.time.LocalDate;
import java.time.Month;
//from   w w  w  .  ja v  a 2s. c om
public class Main {
  public static void main(String[] args) {
    Month m = Month.from(LocalDate.now());
    
    System.out.println(m.maxLength());

  }
}

The code above generates the following result.