Here you can find the source of formatInt(String value)
Parameter | Description |
---|---|
value | The value validation is being performed on. |
public static Integer formatInt(String value)
//package com.java2s; //License from project: Open Source License public class Main { /**// ww w. ja va 2s. c o m * Checks if the value can safely be converted to a int primitive. * * @param value The value validation is being performed on. * @return format result */ public static Integer formatInt(String value) { if (isBlankOrNull(value)) { return null; } try { return new Integer(value); } catch (NumberFormatException e) { return null; } } /** * <p>Checks if the field isn't null and length of the field is greater than zero not * including whitespace.</p> * * @param value The value validation is being performed on. * @return validation result */ public static boolean isBlankOrNull(String value) { return ((value == null) || (value.trim().length() == 0) || "null".equalsIgnoreCase(value)); } }