/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.time.*;
import java.time.format.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
System.
out.
println("29/02/2016 eh uma data valida? " + isDateValid
("29/02/2016")); System.
out.
println("29/02/2017 eh uma data valida? " + isDateValid
("29/02/2017")); System.
out.
println("31/06/2017 eh uma data valida? " + isDateValid
("30/01/2017")); System.
out.
println("31/04/2017 eh uma data valida? " + isDateValid
("31/04/2017"));
}
public static boolean isDateValid
(String strDate
) { String dateFormat
= "dd/MM/uuuu";
DateTimeFormatter dateTimeFormatter = DateTimeFormatter
.ofPattern(dateFormat)
.withResolverStyle(ResolverStyle.STRICT);
try {
LocalDate date = LocalDate.parse(strDate, dateTimeFormatter);
return true;
} catch (DateTimeParseException e) {
return false;
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnRpbWUuKjsKaW1wb3J0IGphdmEudGltZS5mb3JtYXQuKjsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CiAKCQkJU3lzdGVtLm91dC5wcmludGxuKCIyOS8wMi8yMDE2IGVoIHVtYSBkYXRhIHZhbGlkYT8gIiArIGlzRGF0ZVZhbGlkKCIyOS8wMi8yMDE2IikpOwoJCQlTeXN0ZW0ub3V0LnByaW50bG4oIjI5LzAyLzIwMTcgZWggdW1hIGRhdGEgdmFsaWRhPyAiICsgaXNEYXRlVmFsa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