Close

Java Date Time - YearMonth.isBefore() Examples

Java Date Time Java Java API 


Class:

java.time.YearMonth

java.lang.Objectjava.lang.Objectjava.time.YearMonthjava.time.YearMonthjava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public boolean isBefore(YearMonth other)

Checks if this year-month is before the specified year-month.


Examples


package com.logicbig.example.yearmonth;

import java.time.YearMonth;

public class IsBeforeExample {

public static void main(String... args) {
YearMonth y1 = YearMonth.of(2010, 11);
System.out.println(y1);

YearMonth y2 = YearMonth.of(2000, 5);
System.out.println(y2);

boolean b = y1.isBefore(y2);
System.out.println(b);

boolean b2 = y2.isBefore(y1);
System.out.println(b2);
}
}

Output

2010-11
2000-05
false
true




See Also