Java Parse Decimal parseBigDecimal(String s, NumberFormat format)

Here you can find the source of parseBigDecimal(String s, NumberFormat format)

Description

Parst s volgens format.

License

Open Source License

Declaration

public static BigDecimal parseBigDecimal(String s, NumberFormat format) throws ParseException 

Method Source Code


//package com.java2s;
/*/*from  w w  w  .j  a  va 2  s . co m*/
 * B3P Commons Core is a library with commonly used classes for webapps.
 * Included are clieop3, oai, security, struts, taglibs and other
 * general helper classes and extensions.
 *
 * Copyright 2000 - 2008 B3Partners BV
 * 
 * This file is part of B3P Commons Core.
 * 
 * B3P Commons Core 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, or
 * (at your option) any later version.
 * 
 * B3P Commons Core 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 B3P Commons Core.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.math.BigDecimal;

import java.text.NumberFormat;

import java.text.ParseException;

public class Main {
    /**
     * Parst s volgens format. Returnt null indien s null is of een lege string.
     * Throws wel een exception indien s geen getal is.
     */
    public static BigDecimal parseBigDecimal(String s, NumberFormat format) throws ParseException {
        if (s == null || s.trim().length() == 0) {
            return null;
        } else {

            return new BigDecimal(format.parse(s).doubleValue());
        }
    }
}

Related

  1. parseDecimal(PushbackReader reader)
  2. parseDecimal(String d)
  3. parseDecimal(String text)