Close

Java Date Time - LocalDate.lengthOfMonth() Examples

Java Date Time Java Java API 


Class:

java.time.LocalDate

java.lang.Objectjava.lang.Objectjava.time.LocalDatejava.time.LocalDatejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.time.chrono.ChronoLocalDateChronoLocalDatejava.io.SerializableSerializableLogicBig

Method:

public int lengthOfMonth()

This method returns the number of days in the month corresponding to this local date.


Examples


package com.logicbig.example.localdate;

import java.time.LocalDate;

public class LengthOfMonthExample {

public static void main (String... args) {
LocalDate d = LocalDate.of(1998, 5, 3)
.plusDays(400);
System.out.println(d.lengthOfMonth());
System.out.println(d.getMonth());
}
}

Output

30
JUNE




See Also