[PATCH 06 of 12] issue1542: Let MainValues have localized dates
Wald Commits
scm-commit at wald.intevation.org
Tue Nov 12 17:18:45 CET 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1384254683 -3600
# Node ID 74e9768098a022bbb1e1573132702e1ad8c34917
# Parent 19a133698eaf3e5f21e6066671de063f6ae3cf11
issue1542: Let MainValues have localized dates.
diff -r 19a133698eaf -r 74e9768098a0 artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java Tue Nov 12 11:47:25 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java Tue Nov 12 12:11:23 2013 +0100
@@ -9,6 +9,7 @@
package org.dive4elements.river.artifacts.services;
import java.util.List;
+import java.text.DateFormat;
import org.apache.log4j.Logger;
@@ -32,6 +33,9 @@
import org.dive4elements.river.artifacts.model.RiverFactory;
+import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.utils.Formatter;
+
/**
* This service returns the main values of a river's gauge based on the start
@@ -44,7 +48,6 @@
/** The logger that is used by this service.*/
private static Logger logger = Logger.getLogger(MainValuesService.class);
-
/** The XPath that points to the river definition of the incoming request.*/
public static final String XPATH_RIVER = "/art:mainvalues/art:river/text()";
@@ -54,6 +57,9 @@
/** The XPath that points to the end definition of the incoming request.*/
public static final String XPATH_END = "/art:mainvalues/art:end/text()";
+ protected CallMeta callMeta;
+
+
/**
* The default constructor.
*/
@@ -74,6 +80,8 @@
) {
logger.debug("MainValuesService.process");
+ this.callMeta = callMeta;
+
River river = getRequestedRiver(data);
if (river == null) {
return error("no river found.");
@@ -321,12 +329,15 @@
cr.addAttr(el, "name", namedMainValue.getName());
cr.addAttr(el, "type", mainValueType.getName());
if (mainValue.getTimeInterval() != null) {
- // TODO instead of bulky toString, use i18n.
+ DateFormat df =
+ DateFormat.getDateInstance(DateFormat.SHORT, Resources.getLocale(callMeta));
if (mainValue.getTimeInterval().getStartTime() != null) {
- cr.addAttr(el, "starttime", ""+mainValue.getTimeInterval().getStartTime());
+ cr.addAttr(el, "starttime",
+ df.format(mainValue.getTimeInterval().getStartTime()));
}
if (mainValue.getTimeInterval().getStopTime() != null) {
- cr.addAttr(el, "stoptime", ""+mainValue.getTimeInterval().getStopTime());
+ cr.addAttr(el, "stoptime",
+ df.format(mainValue.getTimeInterval().getStopTime()));
}
}
More information about the Dive4elements-commits
mailing list