Example usage for java.time MonthDay equals

List of usage examples for java.time MonthDay equals

Introduction

In this page you can find the example usage for java.time MonthDay equals.

Prototype

@Override
public boolean equals(Object obj) 

Source Link

Document

Checks if this month-day is equal to another month-day.

Usage

From source file:Main.java

public static void main(String[] args) {
    MonthDay m = MonthDay.now();

    System.out.println(m.equals(MonthDay.of(Month.APRIL, 1)));

}

From source file:Main.java

public static void main(String[] argv) {
    LocalDate dateOfBirth = LocalDate.now();
    MonthDay birthday = MonthDay.of(dateOfBirth.getMonth(), dateOfBirth.getDayOfMonth());
    MonthDay currentMonthDay = MonthDay.from(LocalDate.now());

    if (currentMonthDay.equals(birthday)) {
        System.out.println("Yes!!");
    } else {/*ww  w .  j  a  v  a 2 s .com*/
        System.out.println("Sorry, today is not your birthday");
    }
}