Java Utililty Methods Long Number Create

List of utility methods to do Long Number Create

Description

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

Method

longtoLong(final String bitString)
Convert a bit string into a long value.
assert (bitString.length() <= Long.SIZE);
long value = 0;
for (final char ch : bitString.toCharArray()) {
    if (ch == '1') {
        value = value << 1;
        value = value | 1;
    } else if (ch == '0') {
        value = value << 1;
...
longtoLong(final String str, final long defaultValue)

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

If the string is null, the default value is returned.

 NumberUtils.toLong(null, 1L) = 1L NumberUtils.toLong("", 1L)   = 1L NumberUtils.toLong("1", 0L)  = 1L 
if (str == null) {
    return defaultValue;
try {
    return Long.parseLong(str);
} catch (final NumberFormatException nfe) {
    return defaultValue;
LongtoLong(final String value)
Converts a String to a long plus if the String is NULL, the returned value will be NULL.
if (value == null) {
    return null;
return Long.valueOf(value);
LongtoLong(final String value)
create Long from str.
return Long.parseLong(value);
longtoLong(final String value)
To long.
if (value == null) {
    return 0L;
String szTemp = "";
for (int i = 0; i < value.length(); i++)
    if (value.charAt(i) != ',') {
        szTemp = szTemp + value.charAt(i);
try {
    final double dd = Double.parseDouble(szTemp);
    final long l1 = (long) dd;
    return l1;
} catch (final NumberFormatException e) {
    final long l = 0L;
    return l;
byte[]toLong(int numBytes, long value)
Big endian.
byte val[] = new byte[numBytes];
toLong(val, 0, numBytes, value);
return val;
longtoLong(int value)
Returns the value of the given int as a long , when treated as unsigned.
return value & INT_MASK;
longtoLong(int x, int z)
Shift two int's together to form a compund key
return ((long) x << 32) + z - Integer.MIN_VALUE;
long[]toLong(int[] a)
to Long
long[] b = new long[a.length];
for (int i = 0; i < a.length; i++) {
    b[i] = a[i];
return b;
longtoLong(int[] x, int length, int M)
to Long
long a = 0;
for (int i = 0; i < length; i++) {
    a |= ((long) x[i] << (M * i));
return a;