import java.util.Arrays;
import java.util.Date;
import java.util.TimeZone;
import java.text.ParseException;
import java.text.SimpleDateFormat;
class Datas {
public static void main
(String[] args
) { String[] array
= {"05/09/2016",
"10/10/2012",
"06/09/2016",
"5/4/2012",
"11/11/2016"}; String[] ordenado
= ordenarDatas
(array
); }
sdf.
setTimeZone(TimeZone.
getTimeZone("UTC")); sdf.setLenient(false);
Date[] dates
= new Date[entrada.
length]; for (int i = 0; i < entrada.length; i++) {
try {
dates[i] = sdf.parse(entrada[i]);
}
}
for (int i = 0; i < entrada.length; i++) {
resultado[i] = sdf.format(dates[i]);
}
return resultado;
}
}
aW1wb3J0IGphdmEudXRpbC5BcnJheXM7CmltcG9ydCBqYXZhLnV0aWwuRGF0ZTsKaW1wb3J0IGphdmEudXRpbC5UaW1lWm9uZTsKaW1wb3J0IGphdmEudGV4dC5QYXJzZUV4Y2VwdGlvbjsKaW1wb3J0IGphdmEudGV4dC5TaW1wbGVEYXRlRm9ybWF0OwoKY2xhc3MgRGF0YXMgewogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIFN0cmluZ1tdIGFycmF5ID0geyIwNS8wOS8yMDE2IiwgIjEwLzEwLzIwMTIiLCAiMDYvMDkvMjAxNiIsICI1LzQvMjAxMiIsICIxMS8xMS8yMDE2In07CiAgICAgICAgU3RyaW5nW10gb3JkZW5hZG8gPSBvcmRlbmFyRGF0YXMoYXJyYXkpOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihBcnJheXMudG9TdHJpbmcob3JkZW5hZG8pKTsKICAgIH0KICAgIAogICAgcHVibGljIHN0YXRpYyBTdHJpbmdbXSBvcmRlbmFyRGF0YXMoU3RyaW5nW10gZW50cmFkYSkgewogICAgICAgIFNpbXBsZURhdGVGb3JtYXQgc2RmID0gbmV3IFNpbXBsZURhdGVGb3JtYXQoImRkL01NL3l5eXkiKTsKICAgICAgICBzZGYuc2V0VGltZVpvbmUoVGltZVpvbmUuZ2V0VGltZVpvbmUoIlVUQyIpKTsKICAgICAgICBzZGYuc2V0TGVuaWVudChmYWxzZSk7CiAgICAgICAgRGF0ZVtdIGRhdGVzID0gbmV3IERhdGVbZW50cmFkYS5sZW5ndGhdOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgZW50cmFkYS5sZW5ndGg7IGkrKykgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgZGF0ZXNbaV0gPSBzZGYucGFyc2UoZW50cmFkYVtpXSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKFBhcnNlRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgCXRocm93IG5ldyBJbGxlZ2FsQXJndW1lbnRFeGNlcHRpb24oZW50cmFkYVtpXSwgZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgQXJyYXlzLnNvcnQoZGF0ZXMpOwogICAgICAgIFN0cmluZ1tdIHJlc3VsdGFkbyA9IG5ldyBTdHJpbmdbZW50cmFkYS5sZW5ndGhdOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgZW50cmFkYS5sZW5ndGg7IGkrKykgewogICAgICAgICAgICByZXN1bHRhZG9baV0gPSBzZGYuZm9ybWF0KGRhdGVzW2ldKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHJlc3VsdGFkbzsKICAgIH0KfQ==