当t2是12:00的时候,date2就会变成00:00,然后返回false。别的数据都正常
public static boolean largerTime(String t1,String t2) { Date date1 ,date2; DateFormat formart = new SimpleDateFormat("hh:mm"); try { date1 = formart.parse(t1); date2 = formart.parse(t2); if(date1.compareTo(date2)<0) { return false; } else { return true; } } catch (ParseException e) { System.out.println("date init fail!"); e.printStackTrace(); return false; } }