Mercurial > dive4elements > river
annotate 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 |
rev | line source |
---|---|
6865
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 * |
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 */ |
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 |
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.
gernotbelger
parents:
6865
diff
changeset
|
9 package org.dive4elements.river.artifacts.states.fixation; |
6865
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 |
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.text.DateFormat; |
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.
gernotbelger
parents:
6865
diff
changeset
|
12 import java.util.Calendar; |
6865
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
13 import java.util.Date; |
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.
gernotbelger
parents:
6865
diff
changeset
|
14 import java.util.TimeZone; |
6865
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 |
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.
gernotbelger
parents:
6865
diff
changeset
|
16 final class UniqueDateFormatter { |
6865
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 |
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.
gernotbelger
parents:
6865
diff
changeset
|
18 private final DateFormat df; |
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.
gernotbelger
parents:
6865
diff
changeset
|
19 |
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.
gernotbelger
parents:
6865
diff
changeset
|
20 public UniqueDateFormatter(final DateFormat df) { |
6865
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 this.df = df; |
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
22 } |
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
23 |
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.
gernotbelger
parents:
6865
diff
changeset
|
24 public String format(final Date date) { |
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.
gernotbelger
parents:
6865
diff
changeset
|
25 |
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.
gernotbelger
parents:
6865
diff
changeset
|
26 // FIXME: depends on zone of the dates inside the database, TODO: check this |
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.
gernotbelger
parents:
6865
diff
changeset
|
27 final TimeZone zone = TimeZone.getTimeZone("GMT+1"); |
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.
gernotbelger
parents:
6865
diff
changeset
|
28 final Calendar instance = Calendar.getInstance(zone); |
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.
gernotbelger
parents:
6865
diff
changeset
|
29 instance.setTime(date); |
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.
gernotbelger
parents:
6865
diff
changeset
|
30 |
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.
gernotbelger
parents:
6865
diff
changeset
|
31 final int hour = instance.get(Calendar.HOUR_OF_DAY); |
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.
gernotbelger
parents:
6865
diff
changeset
|
32 |
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.
gernotbelger
parents:
6865
diff
changeset
|
33 final String formatted = this.df.format(date); |
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.
gernotbelger
parents:
6865
diff
changeset
|
34 |
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.
gernotbelger
parents:
6865
diff
changeset
|
35 if (hour == 0) |
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.
gernotbelger
parents:
6865
diff
changeset
|
36 return formatted; |
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.
gernotbelger
parents:
6865
diff
changeset
|
37 |
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.
gernotbelger
parents:
6865
diff
changeset
|
38 // return formatted; |
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.
gernotbelger
parents:
6865
diff
changeset
|
39 return String.format("%s (%s)", formatted, hour); |
6865
90f66b4fc34d
Factored our date formatter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
40 } |
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.
gernotbelger
parents:
6865
diff
changeset
|
41 } |