比较两个时分秒时间的大小

来源:互联网 发布:计算机专业不喜欢编程 编辑:程序博客网 时间:2024/05/22 06:05
public static boolean compTime(String s1,String s2){try {if (s1.indexOf(":")<0||s1.indexOf(":")<0) {System.out.println("格式不正确");}else{String[]array1 = s1.split(":");int total1 = Integer.valueOf(array1[0])*3600+Integer.valueOf(array1[1])*60+Integer.valueOf(array1[2]);String[]array2 = s2.split(":");int total2 = Integer.valueOf(array2[0])*3600+Integer.valueOf(array2[1])*60+Integer.valueOf(array2[2]);return total1-total2>0?true:false;}} catch (NumberFormatException e) {// TODO Auto-generated catch blockreturn true;}return false;}

0 0
原创粉丝点击