Java Integer Format formatInt(String value, int defaultValue)

Here you can find the source of formatInt(String value, int defaultValue)

Description

format Int

License

Apache License

Declaration

public static int formatInt(String value, int defaultValue) 

Method Source Code

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

public class Main {

    public static int formatInt(String value, int defaultValue) {
        try {//from  w w w  .j  av a 2s. c  o m
            if (isNotEmpty(value)) {
                return Integer.valueOf(value).intValue();
            } else {
                return defaultValue;
            }
        } catch (Exception e) {
            return defaultValue;
        }
    }

    public static boolean isNotEmpty(String str) {
        return null != str && !str.trim().equals("");
    }
}

Related

  1. formatInt(int value, int length)
  2. formatInt(int value, int numDigit)
  3. formatInt(int value, int width)
  4. formatInt(String value)
  5. formatInt(String value)
  6. formatInt2(int n)
  7. formatInt64(long val)
  8. formatIntAsDottedOctet(int value)
  9. formatIntAsIpAddress(final int address)