Java DecimalFormat: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=Internal= * java Format") |
No edit summary |
||
Line 1: | Line 1: | ||
=External= | |||
* http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html | |||
=Internal= | =Internal= | ||
* [[java Format#Subjects|java Format]] | * [[java Format#Subjects|java Format]] | ||
* [[java SimpleDateFormat|SimpleDateFormat]] | |||
* [[java String.format()|String.format()]] | |||
!!!Overview | |||
<font color=red>'#' means display the digit if ? It does not fill up with space.</font> | |||
!!!Simplest | |||
{{{ | |||
private static final Format THREAD_NUMBER_FORMAT = new DecimalFormat("000"); | |||
... | |||
THREAD_NUMBER_FORMAT.format(index); | |||
}}} | |||
!!!Float/Double with Two Decimals | |||
{{{ | |||
private static final Format AVERAGE_DURATION_FORMAT = new DecimalFormat("#.00"); | |||
... | |||
AVERAGE_DURATION_FORMAT.format(value); | |||
}}} | |||
__Referenced by:__\\ | |||
[{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=20, maxwidth=50}] |
Revision as of 18:01, 22 January 2016
External
Internal
!!!Overview
'#' means display the digit if ? It does not fill up with space.
!!!Simplest
{{{
private static final Format THREAD_NUMBER_FORMAT = new DecimalFormat("000");
...
THREAD_NUMBER_FORMAT.format(index);
}}}
!!!Float/Double with Two Decimals
{{{
private static final Format AVERAGE_DURATION_FORMAT = new DecimalFormat("#.00");
...
AVERAGE_DURATION_FORMAT.format(value);
}}}
__Referenced by:__\\ [{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=20, maxwidth=50}]