fork(1) 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. // DOB: 2000-12-24
  15. var dob = LocalDate.of(2000, 12, 24);
  16.  
  17. // Minimum age: 18 years
  18. var birthdayAge18years = dob.plusYears(18);
  19. // Maximum age: 75 years
  20. var birthdayAge75years = dob.plusYears(75);
  21.  
  22. var today = LocalDate.now();
  23.  
  24. // is today after 18th birthday and before 75th
  25. var olderThanOr18 = today.equals(birthdayAge18years) || today.isAfter(birthdayAge18years);
  26. System.out.println(birthdayAge18years + " > older than or exactly 18 years: " + olderThanOr18);
  27. var youngerThanOr75 = today.equals(birthdayAge75years) || today.isBefore(birthdayAge75years);
  28. System.out.println(birthdayAge75years + " > younger than or exactly 75 years: " + youngerThanOr75);
  29.  
  30. }
  31. }
Success #stdin #stdout 0.16s 39972KB
stdin
Standard input is empty
stdout
2018-12-24 > older than or exactly 18 years: true
2075-12-24 > younger than or exactly 75 years: true