Java BigDecimal Trim trim(BigDecimal pNombre)

Here you can find the source of trim(BigDecimal pNombre)

Description

trim

License

Open Source License

Declaration

public static BigDecimal trim(BigDecimal pNombre) 

Method Source Code

//package com.java2s;
/**/*  w w  w  .  j av a  2 s . co  m*/
 * This file is part of impotch/util.
 *
 * impotch/util is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License.
 *
 * impotch/util 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with impotch/util.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.math.BigDecimal;

public class Main {

    public static BigDecimal trim(BigDecimal pNombre) {
        BigDecimal nombreTronque = pNombre;
        try {
            while (true) {
                nombreTronque = nombreTronque.setScale(pNombre.scale() - 1);
            }
        } catch (ArithmeticException e) // NOPMD by thirion on 20.12.06 14:39
        {
            // il n'existe plus d 0
        }
        return nombreTronque;
    }
}

Related

  1. trim(BigDecimal n)
  2. trim(BigDecimal val)
  3. trimBigDecimal(BigDecimal n)
  4. truncateAmount(BigDecimal value)
  5. truncByScale(BigDecimal value, int scale)