Repository: incubator-freemarker-site Updated Branches: refs/heads/asf-site 3183eb478 -> b8b70b722
Manual: Noting some common pitfalls when using extended Java decimal format Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/commit/b8b70b72 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/tree/b8b70b72 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/diff/b8b70b72 Branch: refs/heads/asf-site Commit: b8b70b722788b3be421038c0609ccc905be33235 Parents: 3183eb4 Author: ddekany <ddek...@apache.org> Authored: Tue Mar 13 09:53:30 2018 +0100 Committer: ddekany <ddek...@apache.org> Committed: Tue Mar 13 09:53:30 2018 +0100 ---------------------------------------------------------------------- docs/ref_builtins_number.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/blob/b8b70b72/docs/ref_builtins_number.html ---------------------------------------------------------------------- diff --git a/docs/ref_builtins_number.html b/docs/ref_builtins_number.html index c309b9a..af8cd6c 100644 --- a/docs/ref_builtins_number.html +++ b/docs/ref_builtins_number.html @@ -514,6 +514,16 @@ German people write: 12.345.678,00</pre></div> + <div class="callout note"> + <strong class="callout-label">Note:</strong> + + <p>You need at least FreeMarker 2.3.24 for these to work. + Before that, extended Java decimal format parts are just + silently ignored by + <code class="inline-code">java.text.DecimalFormat</code>.</p> + </div> + + <p>FreeMarker extends the Java decimal format patterns with extra options. These options are name-value pairs, specified after two semicolons (<code class="inline-code">;;</code>) at the end of the format @@ -531,6 +541,17 @@ Extended decimal format: ${10002.5?string[",000<strong>;; roundingMode=half <div class="code-wrapper"><pre class="code-block code-output">Standard decimal format: 10,002 Extended decimal format: 10<strong>_</strong>00<strong>3</strong></pre></div> + <div class="callout warning"> + <strong class="callout-label">Warning!</strong> + + <p>A very easy mistake to make is just using a single + semicolon instead of two. It won't even result in an error, as + <code class="inline-code">java.text.DecimalFormat</code> thinks you have just + specified some weird format for negative numbers. So remember to + use two semicolons.</p> + </div> + + <p>Above, in the extended decimal format, we have specified half-up rounding mode and group separator <code class="inline-code">"_"</code>. The table of all options follows (note that these are defined by