1.SimpleDateFormat
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd hh:mm:ss");
Date start = sdf.parse("20140808 12:05:17");
Date end = sdf.parse("20140808 11:04:18");
boolean isTimeout = start.before(end);
if(isTimeout){
System.out.println("is time out");
}else{
System.out.println("not time out");
}
哎,結果是is time out.
因爲小寫的 hh ,12 點會是 00 點。將其修改成大寫 HH 。