comparison artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java @ 9503:83e6acdf8fc6

Fixed: no rounding during calculations (Meilenstein-2 2.9)
author mschaefer
date Fri, 28 Sep 2018 10:11:06 +0200
parents fd6621f47a72
children b9c87bbff6a4
comparison
equal deleted inserted replaced
9502:69a7edd7d1e1 9503:83e6acdf8fc6
6 * documentation coming with Dive4Elements River for details. 6 * documentation coming with Dive4Elements River for details.
7 */ 7 */
8 8
9 package org.dive4elements.river.utils; 9 package org.dive4elements.river.utils;
10 10
11 import java.math.BigDecimal;
12 import java.math.RoundingMode;
13 import java.text.DateFormat; 11 import java.text.DateFormat;
14 import java.text.DecimalFormat; 12 import java.text.DecimalFormat;
15 import java.text.NumberFormat; 13 import java.text.NumberFormat;
16 import java.text.SimpleDateFormat; 14 import java.text.SimpleDateFormat;
17 import java.util.Locale; 15 import java.util.Locale;
383 381
384 public static NumberFormat getFlowDepth(final CallContext context) { 382 public static NumberFormat getFlowDepth(final CallContext context) {
385 return Formatter.getFormatter(context, FLOWDEPTH_MAX_DIGITS, FLOWDEPTH_MAX_DIGITS); 383 return Formatter.getFormatter(context, FLOWDEPTH_MAX_DIGITS, FLOWDEPTH_MAX_DIGITS);
386 } 384 }
387 385
388 /**
389 * Decimal half even rounding of a flow depth value
390 * (ATTENTION: throws an exception for NaN or Infinity!)
391 */
392 public static BigDecimal roundFlowDepth(final double value) {
393 return BigDecimal.valueOf(value).setScale(FLOWDEPTH_MAX_DIGITS, RoundingMode.HALF_EVEN);
394 }
395
396 public static NumberFormat getW(final CallContext context) { 386 public static NumberFormat getW(final CallContext context) {
397 return Formatter.getFormatter(context, 2, 2); 387 return Formatter.getFormatter(context, 2, 2);
398 }
399
400 /**
401 * Decimal half even rounding of a W value
402 * (ATTENTION: throws an exception for NaN or Infinity!)
403 */
404 public static BigDecimal roundW(final double value) {
405 return BigDecimal.valueOf(value).setScale(WATERLEVEL_W_MAX_DIGITS, RoundingMode.HALF_EVEN);
406 } 388 }
407 389
408 /** 390 /**
409 * Another waterlevel formatter with fixed digits (always 2) 391 * Another waterlevel formatter with fixed digits (always 2)
410 */ 392 */

http://dive4elements.wald.intevation.org