@Test public void testGetDecimalStringValueSLO() throws ParseException { final Locale locale = new Locale("sl"); assertEquals("11,667", therapyDisplayProvider.getDecimalStringValue(11.66666, locale)); assertEquals("1,667", therapyDisplayProvider.getDecimalStringValue(1.66666, locale)); assertEquals("0,667", therapyDisplayProvider.getDecimalStringValue(0.66666, locale)); assertEquals("0,0667", therapyDisplayProvider.getDecimalStringValue(0.06666, locale)); assertEquals("0,00667", therapyDisplayProvider.getDecimalStringValue(0.006666, locale)); assertEquals("0,000667", therapyDisplayProvider.getDecimalStringValue(0.0006666, locale)); assertEquals("1", therapyDisplayProvider.getDecimalStringValue(1.0000006, locale)); assertEquals("1,007", therapyDisplayProvider.getDecimalStringValue(1.006666, locale)); assertEquals("0", therapyDisplayProvider.getDecimalStringValue(0.0, locale)); assertEquals("", therapyDisplayProvider.getDecimalStringValue(null, locale)); }
public String getDecimalStringValue(final Double value, final Locale locale) throws ParseException { final boolean isDecimalNumber = value != null && value < 1 && value != 0; if (isDecimalNumber) { final String[] numberSplittedByDecimalPoint = BigDecimal.valueOf(value).toPlainString().split("\\."); final Pattern pattern = Pattern.compile("[1-9]"); final Matcher matcher = pattern.matcher(numberSplittedByDecimalPoint[1]); if (matcher.find()) { final int firstNonZeroNumberPosition = matcher.start(); final String hashes = StringUtils.repeat("#", firstNonZeroNumberPosition + 3); return NumberFormatters.adjustableDoubleFormatter("0." + hashes, locale).valueToString(value); } } return NumberFormatters.doubleFormatter3(locale).valueToString(value); }
TherapyDisplayProvider { public String getDecimalStringValue(final Double value, final Locale locale) throws ParseException { final boolean isDecimalNumber = value != null && value < 1 && value != 0; if (isDecimalNumber) { final String[] numberSplittedByDecimalPoint = BigDecimal.valueOf(value).toPlainString().split("\\."); final Pattern pattern = Pattern.compile("[1-9]"); final Matcher matcher = pattern.matcher(numberSplittedByDecimalPoint[1]); if (matcher.find()) { final int firstNonZeroNumberPosition = matcher.start(); final String hashes = StringUtils.repeat("#", firstNonZeroNumberPosition + 3); return NumberFormatters.adjustableDoubleFormatter("0." + hashes, locale).valueToString(value); } } return NumberFormatters.doubleFormatter3(locale).valueToString(value); } }
TherapyDisplayProvider { public String getDecimalStringValue(final Double value, final Locale locale) throws ParseException { final boolean isDecimalNumber = value != null && value < 1 && value != 0; if (isDecimalNumber) { final String[] numberSplittedByDecimalPoint = BigDecimal.valueOf(value).toPlainString().split("\\."); final Pattern pattern = Pattern.compile("[1-9]"); final Matcher matcher = pattern.matcher(numberSplittedByDecimalPoint[1]); if (matcher.find()) { final int firstNonZeroNumberPosition = matcher.start(); final String hashes = StringUtils.repeat("#", firstNonZeroNumberPosition + 3); return NumberFormatters.adjustableDoubleFormatter("0." + hashes, locale).valueToString(value); } } return NumberFormatters.doubleFormatter3(locale).valueToString(value); }  }
TherapyDisplayProvider { public String getDecimalStringValue(final Double value, final Locale locale) throws ParseException { final boolean isDecimalNumber = value != null && value < 1 && value != 0; if (isDecimalNumber) { final String[] numberSplittedByDecimalPoint = BigDecimal.valueOf(value).toPlainString().split("\\."); final Pattern pattern = Pattern.compile("[1-9]"); final Matcher matcher = pattern.matcher(numberSplittedByDecimalPoint[1]); if (matcher.find()) { final int firstNonZeroNumberPosition = matcher.start(); final String hashes = StringUtils.repeat("#", firstNonZeroNumberPosition + 3); return NumberFormatters.adjustableDoubleFormatter("0." + hashes, locale).valueToString(value); } } return NumberFormatters.doubleFormatter3(locale).valueToString(value); }  void fillDisplayValues(
      final TherapyDto therapy,
      final boolean showLongFormattedDescription,
      final boolean showTherapyInterval,
      final Locale locale); void fillDisplayValues(
      final TherapyDto therapy,
      final boolean showLongFormattedDescription,
      final boolean showTherapyInterval,
      final boolean showTherapyDuration,
      final Locale locale,
      final boolean showCommentOnShortFormat); String getFormattedDecimalValue(final String decimalValue, final Locale locale, final boolean bold); String getMedicationDisplay(final MedicationSimpleDto medication); String getRateDisplayString(final Double rate, final String rateUnit, final Locale locale); String getDecimalStringValue(final Double value, final Locale locale); }
TherapyDisplayProvider { public String getDecimalStringValue(final Double value, final Locale locale) throws ParseException { final boolean isDecimalNumber = value != null && value < 1 && value != 0; if (isDecimalNumber) { final String[] numberSplittedByDecimalPoint = BigDecimal.valueOf(value).toPlainString().split("\\."); final Pattern pattern = Pattern.compile("[1-9]"); final Matcher matcher = pattern.matcher(numberSplittedByDecimalPoint[1]); if (matcher.find()) { final int firstNonZeroNumberPosition = matcher.start(); final String hashes = StringUtils.repeat("#", firstNonZeroNumberPosition + 3); return NumberFormatters.adjustableDoubleFormatter("0." + hashes, locale).valueToString(value); } } return NumberFormatters.doubleFormatter3(locale).valueToString(value); }  void fillDisplayValues(
      final TherapyDto therapy,
      final boolean showLongFormattedDescription,
      final boolean showTherapyInterval,
      final Locale locale); void fillDisplayValues(
      final TherapyDto therapy,
      final boolean showLongFormattedDescription,
      final boolean showTherapyInterval,
      final boolean showTherapyDuration,
      final Locale locale,
      final boolean showCommentOnShortFormat); String getFormattedDecimalValue(final String decimalValue, final Locale locale, final boolean bold); String getMedicationDisplay(final MedicationSimpleDto medication); String getRateDisplayString(final Double rate, final String rateUnit, final Locale locale); String getDecimalStringValue(final Double value, final Locale locale);  }