java - ByteBuffer to bigdecimal, binary, string -
**please check edit @ bottom of post
have bytebuffer[128 bits] [which has numbers] need convert bigdecimal, binary, string since these corresponding sql mapping while using jdbc.
is there library api can make use of this. see string.valueof() not take byte array parameter.so stuck doing this:
bigdecimal bd = new bigdecimal(bigmybuffer.ascharbuffer().tostring()); this looks hack me ?. there better way of doing or rather doing jdbc part in efficient manner. focused on doing inserts in respective sql columns of now.
edit:
wrong , bytebuffers not numbers sort of bits. need take 128 bit byte buffer , convert 2 longs , merge bigdecimal numbers maintain sanity. this: longbuffer lbuuid = guid.aslongbuffer();
firstlong= lbuuid.get(); secondlong = lbuuid.get(); bigdecimal = firstlong + secondlong ; thanks.
may better detour on biginteger? using biginteger can interpretate byte-array positive large number , biginteger small step bigdecimal:
byte[] data= new byte[] { 0x12, 0x04, 0x07, 0x05, 0x08, 0x11, 0x38, 0x44, 0x77, 0x33}; biginteger bi =new biginteger(1,data); bigdecimal bd = new bigdecimal(bi);
Comments
Post a Comment