@Test public void multiDimensions() { assertThat(formatMeasureId.apply("600000.00000000 cm^2"), equalTo("600.000 cm²")); assertThat(formatMeasureId.apply("7511.234 cm/h"), equalTo("7.511,234 cm/h")); assertThat(formatMeasureEn.apply("7511.234 " + SI.WATT.times(1000).times(NonSI.HOUR)), equalTo("7,511.234 kW·h")); }
@Override @Nullable public String apply(@Nullable String input) { if (!Strings.isNullOrEmpty(input)) { try { final Matcher matcher = embeddedPattern.matcher(input); final CurrencyUnit currency; if (matcher.matches()) { final BigDecimal scaled = BigDecimalUtils.stripFractionZeros(new BigDecimal(matcher.group(1))); final String unitCode = matcher.group(2); return measureFormat.format(Measure.valueOf(scaled, Unit.valueOf(unitCode))); } else { return numberFormat.format(new Double(input)); } } catch (Exception e) { log.error("Cannot formatMeasure from " + input, e); return input; } } else { return ""; } }
FormatMeasure implements
		Function<String, String> { @Override @Nullable public String apply(@Nullable String input) { if (!Strings.isNullOrEmpty(input)) { try { final Matcher matcher = embeddedPattern.matcher(input); final CurrencyUnit currency; if (matcher.matches()) { final BigDecimal scaled = BigDecimalUtils.stripFractionZeros(new BigDecimal(matcher.group(1))); final String unitCode = matcher.group(2); return measureFormat.format(Measure.valueOf(scaled, Unit.valueOf(unitCode))); } else { return numberFormat.format(new Double(input)); } } catch (Exception e) { log.error("Cannot formatMeasure from " + input, e); return input; } } else { return ""; } } }
FormatMeasure implements
		Function<String, String> { @Override @Nullable public String apply(@Nullable String input) { if (!Strings.isNullOrEmpty(input)) { try { final Matcher matcher = embeddedPattern.matcher(input); final CurrencyUnit currency; if (matcher.matches()) { final BigDecimal scaled = BigDecimalUtils.stripFractionZeros(new BigDecimal(matcher.group(1))); final String unitCode = matcher.group(2); return measureFormat.format(Measure.valueOf(scaled, Unit.valueOf(unitCode))); } else { return numberFormat.format(new Double(input)); } } catch (Exception e) { log.error("Cannot formatMeasure from " + input, e); return input; } } else { return ""; } } FormatMeasure(Locale locale); }
FormatMeasure implements
		Function<String, String> { @Override @Nullable public String apply(@Nullable String input) { if (!Strings.isNullOrEmpty(input)) { try { final Matcher matcher = embeddedPattern.matcher(input); final CurrencyUnit currency; if (matcher.matches()) { final BigDecimal scaled = BigDecimalUtils.stripFractionZeros(new BigDecimal(matcher.group(1))); final String unitCode = matcher.group(2); return measureFormat.format(Measure.valueOf(scaled, Unit.valueOf(unitCode))); } else { return numberFormat.format(new Double(input)); } } catch (Exception e) { log.error("Cannot formatMeasure from " + input, e); return input; } } else { return ""; } } FormatMeasure(Locale locale); @Override @Nullable String apply(@Nullable String input); }
FormatMeasure implements
		Function<String, String> { @Override @Nullable public String apply(@Nullable String input) { if (!Strings.isNullOrEmpty(input)) { try { final Matcher matcher = embeddedPattern.matcher(input); final CurrencyUnit currency; if (matcher.matches()) { final BigDecimal scaled = BigDecimalUtils.stripFractionZeros(new BigDecimal(matcher.group(1))); final String unitCode = matcher.group(2); return measureFormat.format(Measure.valueOf(scaled, Unit.valueOf(unitCode))); } else { return numberFormat.format(new Double(input)); } } catch (Exception e) { log.error("Cannot formatMeasure from " + input, e); return input; } } else { return ""; } } FormatMeasure(Locale locale); @Override @Nullable String apply(@Nullable String input);  }