KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to change a values in byte array to put a long timestamp value in in the MSBs. Can someone tell me whats the best way to do it. I do not want to insert values bit-by-bit which I believe is very inefficient. long time = System.currentTimeMillis(); Long timeStamp = new Long(time); byte[] bArray = new byte[128]; What I want is something like: byte[0-63] = timeStamp.byteValue(); Is something like this possible . What is the best way to edit/insert values in this byte array. since byte is a primitive I dont think there are some direct implementations I can make use of? Edit: It seems that System.currentTimeMillis() is faster than Calendar.getTimeInMillis() , so replacing the above code by it.Please correct me if wrong.
Tags (comma-separated)
Save Edits
Cancel