Java Number Format Pattern getSeparator(final NumberFormat format)

Here you can find the source of getSeparator(final NumberFormat format)

Description

Returns the separator to use between numbers.

License

Open Source License

Parameter

Parameter Description
format The format used for formatting numbers.

Return

The character to use as a separator between numbers.

Declaration

public static char getSeparator(final NumberFormat format) 

Method Source Code

//package com.java2s;
/*/*from   w  w w.j a v a  2  s . c o  m*/
 *    Geotoolkit.org - An Open Source Java GIS Toolkit
 *    http://www.geotoolkit.org
 *
 *    (C) 2009-2012, Open Source Geospatial Foundation (OSGeo)
 *    (C) 2009-2012, Geomatys
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */

import java.text.NumberFormat;
import java.text.DecimalFormat;

public class Main {
    /**
     * Returns the separator to use between numbers. Current implementation returns the coma
     * character, unless the given number already use the coma as the decimal separator.
     *
     * @param  format The format used for formatting numbers.
     * @return The character to use as a separator between numbers.
     *
     * @since 3.11
     */
    public static char getSeparator(final NumberFormat format) {
        if (format instanceof DecimalFormat) {
            final char c = ((DecimalFormat) format).getDecimalFormatSymbols().getDecimalSeparator();
            if (c == ',') {
                return ';';
            }
        }
        return ',';
    }
}

Related

  1. getNumberOfDays(String year, String month)
  2. getNumberStyleAsInt(String style)
  3. getOneFractionDigitNumberFormat()
  4. getPriceFormat()
  5. getScientificFormatter(int precision)
  6. getStrFormatTwoPoint(float param)
  7. getTeamIDFormat()
  8. getUiNumberFormat()
  9. getUSNumberFormatter()