Java Utililty Methods Short Number Create

List of utility methods to do Short Number Create

Description

The list of methods to do Short Number Create are organized into topic(s).

Method

shorttoShort(String str)
Converts a string to a short .
return Short.parseShort(str);
StringtoShort(String str, int maxLen)
to Short
return toShort(str, maxLen, "...");
shorttoShort(String str, short defaultValue)

Convert a String to an short, returning a default value if the conversion fails.

if (str == null) {
    return defaultValue;
try {
    return Short.parseShort(str);
} catch (NumberFormatException nfe) {
    return defaultValue;
shorttoShort(String value)
to Short
if (!isBinary(value))
    return 0;
if (value.length() > 7)
    return 127;
return (short) Integer.parseInt(value, 2);
shorttoShort(String value)
to Short
return toShort(value, (short) 0);
ShorttoShort(String value)
to Short
if (null == value) {
    return null;
value = value.trim();
if ("null".equals(value)) {
    return null;
Double d = Double.parseDouble(value);
...
shorttoShort(String value, short defaultValue)
convert the string to an short, and return the default value if the string is null or does not contain a valid int value
if (value != null) {
    try {
        return Short.parseShort(value);
    } catch (NumberFormatException n) {
return defaultValue;
short[]toShort(String[] arr)
to Short
short[] s = new short[arr.length];
for (int i = 0; i < arr.length; ++i)
    s[i] = Short.parseShort(arr[i]);
return s;