Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/UniqueDateFormatter.java @ 9425:3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
Also allows to have acces to the potentially already computed artifact result via its normal computation cache.
author | gernotbelger |
---|---|
date | Fri, 17 Aug 2018 15:31:02 +0200 |
parents | 9744ce3c3853 |
children |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.artifacts.states.fixation; import java.text.DateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; final class UniqueDateFormatter { private final DateFormat df; public UniqueDateFormatter(final DateFormat df) { this.df = df; } public String format(final Date date) { // FIXME: depends on zone of the dates inside the database, TODO: check this final TimeZone zone = TimeZone.getTimeZone("GMT+1"); final Calendar instance = Calendar.getInstance(zone); instance.setTime(date); final int hour = instance.get(Calendar.HOUR_OF_DAY); final String formatted = this.df.format(date); if (hour == 0) return formatted; // return formatted; return String.format("%s (%s)", formatted, hour); } }