6 |
import org.simpleframework.xml.Root; |
import org.simpleframework.xml.Root; |
7 |
|
|
8 |
@Root(name="train", strict=false) |
@Root(name="train", strict=false) |
9 |
public class DepartureEntry implements Comparable<DepartureEntry>, Serializable { |
public class DepartureEntry implements Serializable { |
10 |
|
|
11 |
@Element |
@Element |
12 |
private String time; |
private String time; |
93 |
this.type = type; |
this.type = type; |
94 |
} |
} |
95 |
|
|
|
@Override |
|
|
public int compareTo(DepartureEntry otherBean) { |
|
|
String timeStr1 = time.replace(":","").trim(); |
|
|
String timeStr2 = otherBean.time.replace(":","").trim(); |
|
|
|
|
|
int time1 = 0; |
|
|
int time2 = 0; |
|
|
|
|
|
if (timeStr1.length() > 0) |
|
|
time1 = Integer.parseInt(timeStr1); |
|
|
|
|
|
if (timeStr2.length() > 0) |
|
|
time2 = Integer.parseInt(timeStr2); |
|
|
|
|
|
//work correctly when clock wraps around at midnight |
|
|
if (Math.abs(time1-time2) < 1200) { |
|
|
if (time1 > time2) |
|
|
return 1; |
|
|
else |
|
|
return -1; |
|
|
} else { |
|
|
if (time1 < time2) |
|
|
return 1; |
|
|
else |
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
96 |
} |
} |