NumberUtil { public static int parseInt(byte[] bytes, int start, int length) { return parseInt(bytes, start, length, 10); }  static long unsigned32(int n); static int unsigned16(short n); static byte[] toAsciiBytes(Number i); static byte[] toAsciiBytes(short i); static byte[] toAsciiBytes(int i); static byte[] toAsciiBytes(long i); static byte[] toAsciiBytes(float i); static byte[] toAsciiBytes(double i); static double parseDouble(byte[] bytes, int start, int length); static int parseInt(byte[] bytes, int start, int length); static int parseInt(byte[] bytes, int start, int length, int radix); static long parseLong(byte[] bytes, int start, int length); static long parseLong(byte[] bytes, int start, int length, int radix); static void writeUTF8(OutputStream out, int i); static void writeUTF8(OutputStream out, long i); static double parseDouble(ByteBuf bytes); static double parseDouble(ByteBuf bytes, int start, int length); static int parseInt(ByteBuf bytes); static int parseInt(ByteBuf bytes, int start, int length); static int parseInt(ByteBuf bytes, int start, int length, int radix); static long parseLong(ByteBuf bytes); static long parseLong(ByteBuf bytes, int start, int length); static long parseLong(ByteBuf bytes, int start, int length, int radix); static Number numberValue(Class<?> numberClazz, String value); static long mergeToLong(int value1, int value2); static int toHighInt(long value); static int toLowInt(long value); static final double[] powersOf10; }
@Test public void testParseInt() { int int1 = 0; byte[] bytes1 = Double.toString(int1).getBytes(); assertEquals(int1, NumberUtil.parseInt(bytes1, 0, bytes1.length)); int int2 = -7; byte[] bytes2 = Double.toString(int2).getBytes(); assertEquals(int2, NumberUtil.parseInt(bytes2, 0, bytes2.length)); int int3 = +128; byte[] bytes3 = Double.toString(int3).getBytes(); assertEquals(int3, NumberUtil.parseInt(bytes3, 0, bytes3.length)); int int4 = 4; byte[] bytes4 = Double.toString(int4).getBytes(); assertEquals(int4, NumberUtil.parseInt(bytes4, 0, bytes4.length)); byte[] bytes5 = "0123-456789".getBytes(); assertEquals(-456, NumberUtil.parseInt(bytes5, 4, 4)); }