Mercurial > dive4elements > river
changeset 8397:da67b2bca1c0
Fixing overview filter: Accept date range as UNIX time stamps, too.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 09 Oct 2014 11:57:17 +0200 (2014-10-09) |
parents | a201d475e50d |
children | ae750e3fa9ea |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/FixingsFilterBuilder.java |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FixingsFilterBuilder.java Wed Oct 08 16:28:02 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FixingsFilterBuilder.java Thu Oct 09 11:57:17 2014 +0200 @@ -11,9 +11,7 @@ import org.dive4elements.river.artifacts.model.FixingsOverview.AndFilter; import org.dive4elements.river.artifacts.model.FixingsOverview.DateFilter; import org.dive4elements.river.artifacts.model.FixingsOverview.DateRangeFilter; - import org.dive4elements.river.artifacts.model.FixingsOverview.Fixing.Filter; - import org.dive4elements.river.artifacts.model.FixingsOverview.IdFilter; import org.dive4elements.river.artifacts.model.FixingsOverview.IdsFilter; import org.dive4elements.river.artifacts.model.FixingsOverview.KmFilter; @@ -24,13 +22,13 @@ import java.text.ParsePosition; import java.text.SimpleDateFormat; - import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.log4j.Logger; - import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -40,6 +38,8 @@ { private static Logger log = Logger.getLogger(FixingsFilterBuilder.class); + private static final Pattern IS_LONG = Pattern.compile("^\\s*(-?\\d+)\\s*$"); + protected Filter filter; protected Range range; @@ -131,6 +131,10 @@ } protected static final Date parseDate(String text) { + Matcher m = IS_LONG.matcher(text); + if (m.matches()) { + return new Date(Long.valueOf(m.group(1))); + } SimpleDateFormat format = new SimpleDateFormat(FixingsOverview.DATE_FORMAT); return format.parse(text, new ParsePosition(0));