Java Program to Check the birthday and print Happy Birthday message

To understand this example, you should have the knowledge of the following Java programming topics:


Example: Check birthday and return Happy Birthday message

Output 1

Todays Date: 2020-07-28
HAPPY BIRTHDAY TO YOU !!

In the above example,

  • LocalDate.now() - returns the current date
  • getDayOfMonth() - returns the current day
  • getMonth() - returns the current month

Here, we have used the if...else statement to check if the current date matches the birthdate. If true, the Happy Birthday message is printed.