Mercurial > dive4elements > river
changeset 5896:45871a108aae
Backend: Fixed constructor of ImportTimeInterval.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 03 May 2013 13:06:14 +0200 |
parents | 4110565baff8 |
children | 39cf5d4acf5d |
files | backend/src/main/java/org/dive4elements/river/importer/ImportTimeInterval.java |
diffstat | 1 files changed, 23 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportTimeInterval.java Fri May 03 12:51:29 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportTimeInterval.java Fri May 03 13:06:14 2013 +0200 @@ -31,29 +31,30 @@ } public ImportTimeInterval(Date startTime) { - this.startTime = startTime; - this.stopTime = null; + this(startTime, null); } public ImportTimeInterval(Date startTime, Date stopTime) { - Date start; - Date stop; - if (startTime == null) { - start = stopTime; - stop = null; - } - else { - start = startTime; - stop = stopTime; - } - if (stop != null && start.after(stop)) { - this.stopTime = start; - this.startTime = stop; + if (startTime != null && stopTime == null) { + this.startTime = startTime; + this.stopTime = null; + } + else if (startTime == null && stopTime != null) { + this.startTime = stopTime; + this.stopTime = null; + } + else if (startTime == null && stopTime == null) { + throw new IllegalArgumentException("Both dates are null."); } else { - this.startTime = start; - this.stopTime = stop; + if (startTime.after(stopTime)) { + Date t = startTime; + startTime = stopTime; + stopTime = t; + } + this.startTime = startTime; + this.stopTime = stopTime; } } @@ -102,5 +103,10 @@ } return peer; } + + @Override + public String toString() { + return "start time: " + startTime + ", stop time: " + stopTime; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :