Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/model/DateRange.java @ 9155:9b4f5e61c02e
Changed to list of DateRange, added methods in DateRange to support year ranges
author | mschaefer |
---|---|
date | Tue, 19 Jun 2018 14:15:32 +0200 |
parents | af13ceeba52a |
children | 091fd9676496 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/DateRange.java Thu Jun 14 17:51:30 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/DateRange.java Tue Jun 19 14:15:32 2018 +0200 @@ -11,6 +11,8 @@ import java.io.Serializable; import java.util.Date; +import org.dive4elements.artifacts.common.utils.DateUtils; + public class DateRange implements Serializable { @@ -19,28 +21,28 @@ protected Date from; protected Date to; - public DateRange(Date from, Date to) { + public DateRange(final Date from, final Date to) { this.from = from; this.to = to; } public Date getFrom() { - return from; + return this.from; } - public void setFrom(Date from) { + public void setFrom(final Date from) { this.from = from; } public Date getTo() { - return to; + return this.to; } - public void setTo(Date to) { + public void setTo(final Date to) { this.to = to; } - private static final boolean equalDates(Date a, Date b) { + private static final boolean equalDates(final Date a, final Date b) { if (a == null && b != null) return false; if (a != null && b == null) return false; if (a == null) return true; @@ -48,12 +50,20 @@ } @Override - public boolean equals(Object other) { + public boolean equals(final Object other) { if (!(other instanceof DateRange)) { return false; } - DateRange o = (DateRange)other; - return equalDates(from, o.from) && equalDates(to, o.to); + final DateRange o = (DateRange)other; + return equalDates(this.from, o.from) && equalDates(this.to, o.to); + } + + public int getFromYear() { + return DateUtils.getYearFromDate(this.from); + } + + public int getToYear() { + return DateUtils.getYearFromDate(this.to); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :