Java Decimal Format decimalFormat(Double numeric)

Here you can find the source of decimalFormat(Double numeric)

Description

Format Decimal number

License

Apache License

Parameter

Parameter Description
numeric a parameter

Return

string

Declaration

public static String decimalFormat(Double numeric) 

Method Source Code

//package com.java2s;
/*/*from ww  w  . j a v  a2  s  . c om*/
 ************************************************************************
 Copyright [2011] [PagSeguro Internet Ltda.]

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 ************************************************************************
 */

import java.text.DecimalFormat;

import java.util.Locale;

public class Main {
    private static final int NUMBER_100 = 100;

    /**
     * Format Decimal number
     * 
     * @param numeric
     * @return string
     */
    public static String decimalFormat(Double numeric) {
        Locale.setDefault(new Locale("pt", "BR"));
        DecimalFormat decimal = new DecimalFormat();
        decimal.applyPattern("#,##0.00");
        return decimal.format(numeric / NUMBER_100).replaceAll(",", ".");
    }
}

Related

  1. decimalConversation(double amount)
  2. decimalFormat()
  3. decimalFormat(double d)
  4. decimalFormat(double no)
  5. decimalFormat(double number)
  6. decimalFormat(double value, int decimalCnt)
  7. decimalFormat(Object obj)
  8. decimalFormat(String pattern)
  9. decimalFormat(String pattern, double value)