fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.time.* ;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14.  
  15. int birthDate = 28;
  16. Month birthMonth = Month.DECEMBER ;
  17.  
  18. // get current date
  19. LocalDate currentDate = LocalDate.now();
  20. System.out.println("Todays Date: " + currentDate);
  21.  
  22. // get current date and month
  23. int date = currentDate.getDayOfMonth();
  24. Month month = currentDate.getMonth();
  25.  
  26. if(date == birthDate && month == birthMonth) {
  27. System.out.println("HAPPY BIRTHDAY TO YOU !!");
  28. }
  29. else {
  30. System.out.println("Today is not my birthday.");
  31. }
  32.  
  33. }
  34. }
Success #stdin #stdout 0.15s 51400KB
stdin
Standard input is empty
stdout
Todays Date: 2021-12-28
HAPPY BIRTHDAY TO YOU !!