Numbers { @UserFunction @Description("apoc.number.format(number) | format a long or double using the default system pattern and language to produce a string") public String format(final @Name("number") Object value,@Name(value = "pattern",defaultValue = "") String pattern, @Name(value = "lang", defaultValue = "") String lang) { Number number = validateNumberParam(value); if (number == null) return null; DecimalFormat format = buildFormatter(pattern, lang); if (format == null) return null; return format.format(number); }  @UserFunction @Description("apoc.number.format(number) | format a long or double using the default system pattern and language to produce a string") String format(final @Name("number") Object value,@Name(value = "pattern",defaultValue = "") String pattern, @Name(value = "lang", defaultValue = "") String lang); @UserFunction("apoc.number.parseInt") @Description("apoc.number.parseInt(text) | parse a text using the default system pattern and language to produce a long") Long parseInt(final @Name("text") String text, @Name(value = "pattern",defaultValue = "") String pattern, @Name(value = "lang",defaultValue = "") String lang); @UserFunction("apoc.number.parseFloat") @Description("apoc.number.parseFloat(text) | parse a text using the default system pattern and language to produce a double") Double parseFloat(final @Name("text") String text, @Name(value = "pattern",defaultValue = "") String pattern, @Name(value = "lang",defaultValue = "") String lang);  }
@Test public void testFormat() throws Exception { testCall(db, "RETURN apoc.number.format(12345) AS value", row -> assertEquals("12,345", row.get("value"))); testCall(db, "RETURN apoc.number.format('aaa') AS value", row -> assertEquals(null, row.get("value"))); testCall(db, "RETURN apoc.number.format(12345, '', 'it') AS value", row -> assertEquals("12.345", row.get("value"))); testCall(db, "RETURN apoc.number.format(12345, '', 'apoc') AS value", row -> assertEquals(null, row.get("value"))); testCall(db, "RETURN apoc.number.format(12345, '#,##0.00;(#,##0.00)') AS value", row -> assertEquals("12,345.00", row.get("value"))); testCall(db, "RETURN apoc.number.format(12345, '#,##0.00;(#,##0.00)', 'it') AS value", row -> assertEquals("12.345,00", row.get("value"))); testCall(db, "RETURN apoc.number.format(12345.67) AS value", row -> assertEquals("12,345.67", row.get("value"))); testCall(db, "RETURN apoc.number.format(12345.67, '', 'it') AS value", row -> assertEquals("12.345,67", row.get("value"))); testCall(db, "RETURN apoc.number.format(12345.67, '#,##0.00;(#,##0.00)') AS value", row -> assertEquals("12,345.67", row.get("value"))); testCall(db, "RETURN apoc.number.format(12345.67, '#,##0.00;(#,##0.00)', 'it') AS value", row -> assertEquals("12.345,67", row.get("value"))); }