view artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/UniqueDateFormatter.java @ 9415:9744ce3c3853

Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets. The facets also put the valid station range into their xml-metadata
author gernotbelger
date Thu, 16 Aug 2018 16:27:53 +0200
parents artifacts/src/main/java/org/dive4elements/river/utils/UniqueDateFormatter.java@90f66b4fc34d
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);
    }
}

http://dive4elements.wald.intevation.org