I want to change the values ββin a byte array to put a long timestamp value in MSB. Can someone tell me the best way to do this. I donβt want to insert bit-by-bit values, which I think are very inefficient.
long time = System.currentTimeMillis(); Long timeStamp = new Long(time); byte[] bArray = new byte[128];
I want something like:
byte[0-63] = timeStamp.byteValue();
It is possible. What is the best way to edit / paste values ββinto this byte array. since the byte is primitive, I donβt think there are some direct implementations that I can use?
Edit:
It seems that System.currentTimeMillis() faster than Calendar.getTimeInMillis() , therefore replacing the above code with it. Please correct me if you are mistaken.
java long-integer type-conversion bytearray
codeObserver Nov 28 '10 at 9:13
source share