Java Float Number Format formatFloat(String value)

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

Description

Checks if the value can safely be converted to a float primitive.

License

Open Source License

Parameter

Parameter Description
value The value validation is being performed on.

Return

format result

Declaration

public static Float formatFloat(String value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//w  w  w .  j  a v  a 2s.co  m
     * Checks if the value can safely be converted to a float primitive.
     *
     * @param value The value validation is being performed on.
     * @return format result
     */
    public static Float formatFloat(String value) {
        if (value == null) {
            return null;
        }

        try {
            return new Float(value);
        } catch (NumberFormatException e) {
            return null;
        }

    }
}

Related

  1. formatFloat(double value, int decimals)
  2. formatFloat(float f)
  3. formatFloat(float input, int numDecimals)
  4. formatFloat(float num, int width, int precision)
  5. formatFloat(float val)