public class Test08 {
public static void main(String[] args) throws ParseException {
ArrayList<Date> list = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Scanner sc = new Scanner(System.in);
for (int i = 0; i <3 ; i++) {
System.out.println("请输入第"+(i+1)+"个日期 格式yyyy-MM-dd:");
String time = sc.nextLine();
Date date = sdf.parse(time);
list.add(date);
}
System.out.println("排序前的日期");
for (Date date : list) {
System.out.println(sdf.format(date));
}
Collections.sort(list);
System.out.println("排序后的日期");
for (Date date : list) {
System.out.println(sdf.format(date));
}
}
}