FormatFunction { @FunctionMeta(description = "Format object using message pattern", example = "${w:format(payload.dateFrom,'yyyy-MM-dd')}") public static String format(Object obj, String pattern) { return Formats.forObject().format(obj, pattern); }  @FunctionMeta(description = "Format object using message pattern", example = "${w:format(payload.dateFrom,'yyyy-MM-dd')}") static String format(Object obj, String pattern); @FunctionMeta(description = "Format number with message pattern with auto scaling", example = "${w:formatNumber(12345, '0.#', 'B')}") static String formatNumber(Number data, String pattern, String suffix); @FunctionMeta(description = "Format number in percentage", example = "${w:percentage(4, 11, 2)}") static String percentage(int divisor, int divident, int precision); @FunctionMeta(description = "Shorten a message", example = "${w:shorten('123456789', 5)} will be '1...9'") static String shorten(String str, int maxLength);  }
@SuppressWarnings("deprecation") @Test public void testFormat() { Assert.assertEquals("12345", FormatFunction.format(12345, "0.#")); Assert.assertEquals("12345.0", FormatFunction.format(12345, "0.0")); Assert.assertEquals("12,345.0", FormatFunction.format(12345, "#,##0.0")); Assert.assertEquals(String.valueOf(new Date().getYear() + 1900), FormatFunction.format(new Date(), "yyyy")); }