TherapyDisplayProvider { public String getFormattedDecimalValue(final String decimalValue, final Locale locale, final boolean bold) { if (decimalValue == null || locale == null) { return ""; } final DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale); final Character decimalSeparator = dfs.getDecimalSeparator(); final String splitDelimiter = decimalSeparator.equals(new Character('.')) ? "\\." : ","; String formattedValue = decimalValue; final Pattern p = Pattern.compile("\\d+" + splitDelimiter + "\\d+"); final Matcher m = p.matcher(formattedValue); while (m.find()) { final String[] decimalNumbers = m.group().split(splitDelimiter); if (decimalNumbers.length == 2) { formattedValue = formattedValue.replaceAll( m.group(), decimalNumbers[0] + splitDelimiter + createSpannedValue( decimalNumbers[1], "TextDataSmallerDecimal" + (bold ? " bold" : ""), false)); } } return formattedValue; }  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);  }
@Test public void testGetFormattedDecimalValue() { final Locale locale = new Locale("en"); final String value1 = "3.652"; final String value2 = "3.652 ml"; final String value3 = "3 ml"; final String value4 = "150"; final String value5 = "volume sum equals 150.654 ml"; final String value6 = "volume sum equals 500 ml"; final String value7 = "150.654ml"; final String value8 = "300ml"; final String formattedValue1 = therapyDisplayProvider.getFormattedDecimalValue(value1, locale, false); final String formattedValue2 = therapyDisplayProvider.getFormattedDecimalValue(value2, locale, false); final String formattedValue3 = therapyDisplayProvider.getFormattedDecimalValue(value3, locale, false); final String formattedValue4 = therapyDisplayProvider.getFormattedDecimalValue(value4, locale, false); final String formattedValue5 = therapyDisplayProvider.getFormattedDecimalValue(value5, locale, false); final String formattedValue6 = therapyDisplayProvider.getFormattedDecimalValue(value6, locale, false); final String formattedValue7 = therapyDisplayProvider.getFormattedDecimalValue(value7, locale, false); final String formattedValue8 = therapyDisplayProvider.getFormattedDecimalValue(value8, locale, false); assertEquals("3.<span class='TextDataSmallerDecimal'>652</span>", formattedValue1); assertEquals("3.<span class='TextDataSmallerDecimal'>652</span> ml", formattedValue2); assertEquals("3 ml", formattedValue3); assertEquals("150", formattedValue4); assertEquals("volume sum equals 150.<span class='TextDataSmallerDecimal'>654</span> ml", formattedValue5); assertEquals("volume sum equals 500 ml", formattedValue6); assertEquals("150.<span class='TextDataSmallerDecimal'>654</span>ml", formattedValue7); assertEquals("300ml", formattedValue8); }