Java Utililty Methods Number Format Pattern

List of utility methods to do Number Format Pattern

Description

The list of methods to do Number Format Pattern are organized into topic(s).

Method

DecimalFormatgetFormatter(String pattern)
Create a DecimalFormat instance for the given pattern that uses '.'
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator('.');
return new DecimalFormat(pattern, symbols);
floatgetFormatTwoPoint(float param)
get Format Two Point
param += 0.001;
java.text.DecimalFormat df = new java.text.DecimalFormat("#0.00");
return Float.parseFloat(df.format(param));
DecimalFormatgetFormatWithMinimumDecimals(final int minimumDecimals, final int maximumDecimals)
Get a decimal format with a specific number of minimum and maximum decimals.
if (maximumDecimals < 0) {
    throw new IllegalArgumentException("Negative maximum decimals are invalid.");
} else if (minimumDecimals < 0) {
    throw new IllegalArgumentException("Negative minimum decimals are invalid.");
} else if (minimumDecimals > maximumDecimals) {
    throw new IllegalArgumentException("The minimum decimals have to be lower than the maximum decimals.");
} else if (minimumDecimals == 0 && maximumDecimals == 0) {
    return new DecimalFormat("#0");
...
NumberFormatgetGeographicPositionFormatter()

Returns the number formatter for the geographical position feature.

return GEO_NUM_FORMATTER;
NumberFormatgetIntegerFormat()
get Integer Format
if (intFmt == null) {
    intFmt = NumberFormat.getIntegerInstance();
    intFmt.setGroupingUsed(true);
return intFmt;
DecimalFormatgetIntegerFormat(int maximumIntegerDigits)
get Integer Format
DecimalFormat decimalEditFormat = new DecimalFormat();
decimalEditFormat.setMaximumFractionDigits(0);
decimalEditFormat.setGroupingUsed(false);
decimalEditFormat.setParseIntegerOnly(true);
if (maximumIntegerDigits > 0) {
    decimalEditFormat.setMaximumIntegerDigits(maximumIntegerDigits);
    decimalEditFormat.setMinimumIntegerDigits(maximumIntegerDigits);
return decimalEditFormat;
NumberFormatgetIntegerFormatter()
get Integer Formatter
return DecimalFormat.getIntegerInstance();
NumberFormatgetIntegerNumberFormat()
get Integer Number Format
NumberFormat nf = NumberFormat.getIntegerInstance();
nf.setGroupingUsed(false);
return nf;
NumberFormatgetNeptusIntegerFormat()
get Neptus Integer Format
NumberFormat df = DecimalFormat.getInstance(Locale.US);
df.setGroupingUsed(false);
df.setMaximumFractionDigits(0);
df.setMinimumFractionDigits(0);
df.setParseIntegerOnly(true);
return df;
NumbergetNumber(final Map map, final Object key)
Gets a Number from a Map in a null-safe manner.
if (map != null) {
    Object answer = map.get(key);
    if (answer != null) {
        if (answer instanceof Number) {
            return (Number) answer;
        } else if (answer instanceof String) {
            try {
                String text = (String) answer;
...