comparison flys-aft/src/main/java/de/intevation/aft/TimeInterval.java @ 4089:859b4781554a

Prefetch existing time intervals from FLYS db. flys-aft/trunk@3574 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 03 Jan 2012 12:25:06 +0000
parents
children d556e29592f5
comparison
equal deleted inserted replaced
4088:52cde7fe742a 4089:859b4781554a
1 package de.intevation.aft;
2
3 import java.util.Date;
4
5 public class TimeInterval
6 implements Comparable<TimeInterval>
7 {
8 protected int id;
9 protected Date start;
10 protected Date stop;
11
12 public TimeInterval() {
13 }
14
15 public TimeInterval(int id, Date start, Date stop) {
16 this.id = id;
17 this.start = start;
18 this.stop = stop;
19 }
20
21 protected static int compare(Date d1, Date d2) {
22 long s1 = d1 != null ? d1.getTime()/1000L : 0L;
23 long s2 = d2 != null ? d2.getTime()/1000L : 0L;
24 long diff = s1 - s2;
25 return diff < 0L
26 ? -1
27 : diff > 0L ? 1 : 0;
28 }
29
30 @Override
31 public int compareTo(TimeInterval other) {
32 int cmp = compare(start, other.start);
33 return cmp != 0
34 ? cmp
35 : compare(stop, other.stop);
36 }
37
38 public int getId() {
39 return id;
40 }
41
42 public void setId(int id) {
43 this.id = id;
44 }
45
46 public Date getStart() {
47 return start;
48 }
49
50 public void setStart(Date start) {
51 this.start = start;
52 }
53
54 public Date getStop() {
55 return stop;
56 }
57
58 public void setStop(Date stop) {
59 this.stop = stop;
60 }
61 }
62 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org