Close

Java Date Time - MonthDay.isBefore() Examples

Java Date Time Java Java API 


Class:

java.time.MonthDay

java.lang.Objectjava.lang.Objectjava.time.MonthDayjava.time.MonthDayjava.time.temporal.TemporalAccessorTemporalAccessorjava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public boolean isBefore(MonthDay other)

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


Examples


package com.logicbig.example.monthday;

import java.time.MonthDay;

public class IsBeforeExample {

public static void main(String... args) {
MonthDay m1 = MonthDay.of(10, 21);
System.out.println(m1);

MonthDay m2 = MonthDay.of(5, 15);
System.out.println(m2);

boolean b = m2.isBefore(m1);
System.out.println(b);

boolean b2 = m1.isBefore(m2);
System.out.println(b2);
}
}

Output

--10-21
--05-15
true
false




See Also