Converts a Java long to a Little Endian int on 8 bytes.

@param value is the value to parse.
@return the parsing result
351424
@Pure
	public static byte[] parseLELong(long value) {
		return new byte[] {
			(byte) (value & 0xFF),
			(byte) ((value >> 8) & 0xFF),
			(byte) ((value >> 16) & 0xFF),
			(byte) ((value >> 24) & 0xFF),
			(byte) ((value >> 32) & 0xFF),
			(byte) ((value >> 40) & 0xFF),
			(byte) ((value >> 48) & 0xFF),
			(byte) ((value >> 56) & 0xFF),
		};
    }
620455
public static byte[] convertToExtendedUTF8(long value) {
    //calculate bytes needed
    int bytesNeeded = 1;
    for(int i = 0; i < 7; i++) {
      if(value >= limits[i] ) {
        bytesNeeded++;
      }
    }
    //create space
    byte [] result = new byte[bytesNeeded];
    int byteIndex = 0;
    int inputIndex = 0;
    int bytesLeft = bytesNeeded;
    while(bytesLeft > 1) {
      int midByteMarker = 0x80;//10 in leftmost bits
      int midByteMask = 0x3F;//00111111
      int val = ((int)(value >>> inputIndex) & midByteMask) | midByteMarker;
      result[byteIndex++] = (byte)val;
      inputIndex += 6;
      bytesLeft--;
    }
    int onesNeeded = inputIndex/6;
    if(onesNeeded > 0)
      onesNeeded++;
    int startMask = 255 >>> (onesNeeded + 1);
    int ones = 255 << (8-onesNeeded);
    int val = ((int)(value >>> inputIndex) & startMask) | ones;
    result[byteIndex++] = (byte)val;

    byte[] finalResult = new byte[bytesNeeded];
    for(int i = 0; i < bytesNeeded; i++) {
      int sourceIndex = bytesNeeded-1-i;
      int destIndex = i;
      finalResult[destIndex] = result[sourceIndex];
    }
    if(DEBUG_LEV > 10) {
      System.err.print("input:result_length:result :: " +value+":"+finalResult.length+"::");
      for(int i = 0; i < finalResult.length; i++)
        System.err.print(Integer.toHexString(finalResult[i])+":");
      System.err.println();
    }
    return finalResult;
  }
1181013
@Deprecated
public static byte[] convertLongToVarInt(long value) {
	
	// to make it threadsafe - could be optimized at a later stage
	ByteBuffer longBB = ByteBuffer.allocate(EthereumUtil.LONG_SIZE);
	
	longBB.putLong(value);
	byte[] result = longBB.array();
	int leadingZeros=0;
	for (int i=0;i<result.length;i++) {
		if (result[i]==0) {
			leadingZeros++;
		} else {
			break;
		}
	}
	 return Arrays.copyOfRange(result, leadingZeros, result.length);
}
61485
public static double sortableLongToDouble(long value)
    {
        value = value ^ (value >> 63) & Long.MAX_VALUE;
        return Double.longBitsToDouble(value);
    }
1294446
public Packer putLong(final long value) {
		ensureCapacity(bufPosition + 8);
		buf[bufPosition++] = (byte) (value >> 56);
		buf[bufPosition++] = (byte) (value >> 48);
		buf[bufPosition++] = (byte) (value >> 40);
		buf[bufPosition++] = (byte) (value >> 32);
		buf[bufPosition++] = (byte) (value >> 24);
		buf[bufPosition++] = (byte) (value >> 16);
		buf[bufPosition++] = (byte) (value >> 8);
		buf[bufPosition++] = (byte) (value);
		return this;
	}
384302
private static BigDecimal getBigDecimalOrNull(Object value) {
            if ( !(value instanceof Number || value instanceof String) ) {
                return null;
            }
            if ( !BigDecimal.class.isAssignableFrom( value.getClass() ) ) {
                if ( value instanceof Long || value instanceof Integer || value instanceof Short || value instanceof Byte ||
                     value instanceof AtomicLong || value instanceof AtomicInteger ) {
                    value = new BigDecimal( ((Number) value).longValue(), MathContext.DECIMAL128 );
                } else if ( value instanceof BigInteger ) {
                    value = new BigDecimal( ((BigInteger) value).toString(), MathContext.DECIMAL128 );
                } else if ( value instanceof String ) {
                    // we need to remove leading zeros to prevent octal conversion
                    value = new BigDecimal( ((String) value).replaceFirst("^0+(?!$)", ""), MathContext.DECIMAL128 );
                } else {
                    value = new BigDecimal( ((Number) value).doubleValue(), MathContext.DECIMAL128 );
                }
            }
            return (BigDecimal) value;
        }
664442
public static void longToBytes(long value, byte[] bytes, int offset) {
        for (int i = offset + 7; i >= offset; --i) {
            bytes[i] = (byte) value;
            value = value >> 8;
        }
    }
193199
private static BigInteger decodeBigInteger(String value) {
		int radix = 10;
		int index = 0;
		boolean negative = false;

		// Handle minus sign, if present.
		if (value.startsWith("-")) {
			negative = true;
			index++;
		}

		// Handle radix specifier, if present.
		if (value.startsWith("0x", index) || value.startsWith("0X", index)) {
			index += 2;
			radix = 16;
		}
		else if (value.startsWith("#", index)) {
			index++;
			radix = 16;
		}
		else if (value.startsWith("0", index) && value.length() > 1 + index) {
			index++;
			radix = 8;
		}

		BigInteger result = new BigInteger(value.substring(index), radix);
		return (negative ? result.negate() : result);
	}
663642
private long parseDuration(String value) {
        long periodMS = 0L;
        if (Objects.nonNull(value)) {
            String[] parts = value.split(":");
            for (int i = 0; i < parts.length; i++) {
                switch (i) {
                    case 0: // hours
                        periodMS += (Integer.parseInt(parts[i])) * 3600000L;
                        break;
                    case 1: // minutes
                        periodMS += (Integer.parseInt(parts[i])) * 60000L;
                        break;
                    case 2: // seconds
                        periodMS += (Integer.parseInt(parts[i])) * 1000L;
                        break;
                    case 3: // ms
                        periodMS += (Integer.parseInt(parts[i]));
                        break;
                    default:
                        break;
                }
            }
        }
        return periodMS;
    }
1320762
static long asLong(Object value) throws ProvidenceConfigException {
        if (value instanceof Float || value instanceof Double) {
            long l = ((Number) value).longValue();
            if ((double) l != ((Number) value).doubleValue()) {
                throw new ProvidenceConfigException("Truncating long decimals from " + value.toString());
            }
            return l;
        } else if (value instanceof Number) {
            return ((Number) value).longValue();
        } else if (value instanceof Numeric) {
            return ((Numeric) value).asInteger();
        } else if (value instanceof Boolean) {
            return ((Boolean) value) ? 1L : 0L;
       }
        throw new ProvidenceConfigException("Unable to convert " + value.getClass().getSimpleName() + " to a long");
    }
889462
public static Integer toNullableInteger(Object value) {
		Long result = LongConverter.toNullableLong(value);
		return result != null ? (int) ((long) result) : null;
	}
811926
public static boolean isLongValue(final String value) {
        try {
            Long.parseLong(value);
            return true;
        } catch (final NumberFormatException ex) {
            return false;
        }
    }
469147
public static long toLongValue(String str) throws PageException {
	BigInteger bi = null;
	try {
	    bi = new BigInteger(str);

	}
	catch (Throwable t) {
	    ExceptionUtil.rethrowIfNecessary(t);
	}
	if (bi != null) {
	    if (bi.bitLength() < 64) return bi.longValue();
	    throw new ApplicationException("number [" + str + "] cannot be casted to a long value, number is to long (" + (bi.bitLength() + 1) + " bit)");
	}
	return (long) toDoubleValue(str);
    }
26252
public static long toLong(byte[] b, int off, boolean littleEndian) {
		if (littleEndian) {
			return (toInt(b, off, LITTLE_ENDIAN) & 0xFFFFFFFFL) |
					((toInt(b, off + 4, LITTLE_ENDIAN) & 0xFFFFFFFFL) << 32);
		}
		return ((toInt(b, off, BIG_ENDIAN) & 0xFFFFFFFFL) << 32) |
				(toInt(b, off + 4, BIG_ENDIAN) & 0xFFFFFFFFL);
	}
146211
static long getLong(ByteBuffer buffer) {
        long v = buffer.get();
        long value = v & 0x7F;
        if ((v & 0x80) != 0) {
            v = buffer.get();
            value |= (v & 0x7F) << 7;
            if ((v & 0x80) != 0) {
                v = buffer.get();
                value |= (v & 0x7F) << 14;
                if ((v & 0x80) != 0) {
                    v = buffer.get();
                    value |= (v & 0x7F) << 21;
                    if ((v & 0x80) != 0) {
                        v = buffer.get();
                        value |= (v & 0x7F) << 28;
                        if ((v & 0x80) != 0) {
                            v = buffer.get();
                            value |= (v & 0x7F) << 35;
                            if ((v & 0x80) != 0) {
                                v = buffer.get();
                                value |= (v & 0x7F) << 42;
                                if ((v & 0x80) != 0) {
                                    v = buffer.get();
                                    value |= (v & 0x7F) << 49;
                                    if ((v & 0x80) != 0) {
                                        v = buffer.get();
                                        value |= v << 56;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        value = (value >>> 1) ^ (-(value & 1));
        return value;
    }
931893
public static void writeLongLittleEndian(ByteBuffer io, long value) {
		io.put((byte)(value & 0xFF));
		io.put((byte)((value >> 8) & 0xFF));
		io.put((byte)((value >> 16) & 0xFF));
		io.put((byte)((value >> 24) & 0xFF));
		io.put((byte)((value >> 32) & 0xFF));
		io.put((byte)((value >> 40) & 0xFF));
		io.put((byte)((value >> 48) & 0xFF));
		io.put((byte)((value >> 56) & 0xFF));
	}
1046996
private long convertToLong(byte[] bin){
        ByteBuffer bb = ByteBuffer.wrap(bin);
        bb.order(ByteOrder.BIG_ENDIAN);
        return bb.getInt();
    }