InetAddress ia = InetAddress.getByName("2001:0:4137:9e76:34b7:2e31:3f57:fd9a"); byte ba = ia.getAddress(); System.out.println(Arrays.toString(ba));
Now you have an array of 16 bytes and convert it the way you please.
[32, 1, 0, 0, 65, 55, -98, 118, 52, -73, 46, 49, 63, 87, -3, -102]
I can give bottom and top IP addresses if I can convert an IPv6 address to decimal.You can do that in hex too. Or with BigInteger.
And then when some IPv6 address is encountered to my application, I can convert it into decimal and then check whether it falls in the bottom and top range or not.And you can do that in hex too.
However, I have now successfully converted an IPv6 address to decimal and vice-versa.You can do it with new BigInteger(0,Inet6Address.getAddress()).toString() in one direction, and InetAddress.getByAddress(new BigInteger(String).toByteArray()) in the other direction. But I don't see the point.
The problem now is how to store such a large number (39 digits) in database (I am using derby) in numeric form.No it isn't. Store the 16 bytes in the database. If you must do this calculation in decimal, do the conversions on the fly. At least store the canonical representation in the database, keep your life simple.