Java Parse Number parseNumeric(String value)

Here you can find the source of parseNumeric(String value)

Description

parse Numeric

License

Apache License

Declaration

public static Number parseNumeric(String value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static Number parseNumeric(String value) {
        try {/*from  w ww  .ja  va  2  s . c o m*/
            return Long.parseLong(value);
        } catch (NumberFormatException nfe) {
            try {
                return Double.parseDouble(value);
            } catch (NumberFormatException nfe2) {
                try {
                    return NumberFormat.getInstance().parse(value);
                } catch (ParseException e) {
                    return null;
                }
            }
        }
    }
}

Related

  1. parseNumber(String number)
  2. parseNumber(String s)
  3. parseNumber(String text, Class targetClass)
  4. parseNumber(String text, Class targetClass, NumberFormat numberFormat)
  5. parseNumber(String text, Class targetClass)