Java Parse Number parseNumber(String s)

Here you can find the source of parseNumber(String s)

Description

parse Number

License

Open Source License

Declaration

public static Number parseNumber(String s) 

Method Source Code

//package com.java2s;
/**//w  ww  .  j a v  a  2s .c o  m
 * Mutinack mutation detection program.
 * Copyright (C) 2014-2016 Olivier Cinquin
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, version 3.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

import java.text.NumberFormat;
import java.text.ParseException;

public class Main {
    public static Number parseNumber(String s) {
        try {
            return NumberFormat.getInstance().parse(s);
        } catch (ParseException e) {
            throw new RuntimeException("Could not parse " + s + " to number", e);
        }
    }
}

Related

  1. parseNum(String numStr)
  2. parseNumber(CharacterIterator it)
  3. parseNumber(final String source, final String conversionPattern)
  4. parseNumber(String number)
  5. parseNumber(String number)
  6. parseNumber(String text, Class targetClass)
  7. parseNumber(String text, Class targetClass, NumberFormat numberFormat)
  8. parseNumber(String text, Class targetClass)
  9. parseNumeric(String value)