import java.util.Date;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Stream;
import java.text.SimpleDateFormat;
import java.text.ParseException;
class TesteDatas {
sdf.setLenient(false);
Date[] datas
= {sdf.
parse("02/02/2000"), sdf.
parse("03/03/2000"), sdf.
parse("04/04/2000")}; Date data1
= sdf.
parse("03/01/2000");
// Exemplo 1.
boolean menor1 = true;
if (d.compareTo(data1) < 0) {
menor1 = false;
break;
}
}
System.
out.
println(menor1
? "Era a menor." : "Não era a menor.");
// Exemplo 2.
SortedSet<Date> datas2 = new TreeSet<>();
datas2.add(d);
}
datas2.add(data1);
boolean menor2 = data1.equals(datas2.first());
System.
out.
println(menor2
? "Era a menor." : "Não era a menor.");
// Exemplo 3.
boolean menor3 = Stream.of(datas).allMatch(d -> data1.compareTo(d) < 0);
System.
out.
println(menor3
? "Era a menor." : "Não era a menor."); }
}
aW1wb3J0IGphdmEudXRpbC5EYXRlOwppbXBvcnQgamF2YS51dGlsLlNvcnRlZFNldDsKaW1wb3J0IGphdmEudXRpbC5UcmVlU2V0OwppbXBvcnQgamF2YS51dGlsLnN0cmVhbS5TdHJlYW07CmltcG9ydCBqYXZhLnRleHQuU2ltcGxlRGF0ZUZvcm1hdDsKaW1wb3J0IGphdmEudGV4dC5QYXJzZUV4Y2VwdGlvbjsKCmNsYXNzIFRlc3RlRGF0YXMgewoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBQYXJzZUV4Y2VwdGlvbiB7CgogICAgICAgIFNpbXBsZURhdGVGb3JtYXQgc2RmID0gbmV3IFNpbXBsZURhdGVGb3JtYXQoImRkL01NL3l5eXkiKTsKICAgICAgICBzZGYuc2V0TGVuaWVudChmYWxzZSk7CgogICAgICAgIERhdGVbXSBkYXRhcyA9IHtzZGYucGFyc2UoIjAyLzAyLzIwMDAiKSwgc2RmLnBhcnNlKCIwMy8wMy8yMDAwIiksIHNkZi5wYXJzZSgiMDQvMDQvMjAwMCIpfTsKICAgICAgICBEYXRlIGRhdGExID0gc2RmLnBhcnNlKCIwMy8wMS8yMDAwIik7CgogICAgICAgIC8vIEV4ZW1wbG8gMS4KICAgICAgICBib29sZWFuIG1lbm9yMSA9IHRydWU7CiAgICAgICAgZm9yIChEYXRlIGQgOiBkYXRhcykgewogICAgICAgICAgICBpZiAoZC5jb21wYXJlVG8oZGF0YTEpIDwgMCkgewogICAgICAgICAgICAgICAgbWVub3IxID0gZmFsc2U7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4obWVub3IxID8gIkVyYSBhIG1lbm9yLiIgOiAiTsOjbyBlcmEgYSBtZW5vci4iKTsKCiAgICAgICAgLy8gRXhlbXBsbyAyLgogICAgICAgIFNvcnRlZFNldDxEYXRlPiBkYXRhczIgPSBuZXcgVHJlZVNldDw+KCk7CiAgICAgICAgZm9yIChEYXRlIGQgOiBkYXRhcykgewogICAgICAgICAgICBkYXRhczIuYWRkKGQpOwogICAgICAgIH0KICAgICAgICBkYXRhczIuYWRkKGRhdGExKTsKICAgICAgICBib29sZWFuIG1lbm9yMiA9IGRhdGExLmVxdWFscyhkYXRhczIuZmlyc3QoKSk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKG1lbm9yMiA/ICJFcmEgYSBtZW5vci4iIDogIk7Do28gZXJhIGEgbWVub3IuIik7CgogICAgICAgIC8vIEV4ZW1wbG8gMy4KICAgICAgICBib29sZWFuIG1lbm9yMyA9IFN0cmVhbS5vZihkYXRhcykuYWxsTWF0Y2goZCAtPiBkYXRhMS5jb21wYXJlVG8oZCkgPCAwKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4obWVub3IzID8gIkVyYSBhIG1lbm9yLiIgOiAiTsOjbyBlcmEgYSBtZW5vci4iKTsKICAgIH0KfQ==