• Source
    1. /* package whatever; // don't place package name! */
    2.  
    3. import java.util.*;
    4. import java.lang.*;
    5. import java.io.*;
    6. import java.time.*;
    7.  
    8. /* Name of the class has to be "Main" only if the class is public. */
    9. class Ideone
    10. {
    11. public static void main(String[] args) {
    12. var test = new Scanner(System.in);
    13. while (test.hasNext()) {
    14. var from = LocalDate.parse(test.next());
    15. test.skip(" to ");
    16. var to = LocalDate.parse(test.next());
    17. test.nextLine();
    18. System.out.printf("%s to %s = %s%n", from, to, isMonth(from, to));
    19. }
    20. }
    21.  
    22. static boolean isMonth(LocalDate from, LocalDate to) {
    23. var end = from.plusMonths(1).minusDays(1);
    24. return to.equals(end);
    25. }
    26. }