how to convert long to byte array in java?
<p>I have made <code>long</code> value from byte array using this code</p>

<pre><code>byte[] by = {07, 53 -70, 74};

long value = 0;

for (int i = 0; i &lt; by.length; i++) {
    value =  ((value &lt;&lt; 8) + (by[i] &amp; 0xff));
}

System.out.println(value);
</code></pre>

<p>out put is <code>520010</code></p>

<p>now I want reverse process on this and I tried it this way</p>

<pre><code>long ts = 520010;

tm_stp[0] = (byte) ((byte) ts&gt;&gt;24);
tm_stp[1] = (byte) ((byte) ts&gt;&gt;16);
tm_stp[2] = (byte) ((byte) ts&gt;&gt;8);
tm_stp[3] = (byte) ts;
for (byte b : tm_stp) {
    System.out.println(b);
}
</code></pre>

<p>and output is <code>0 0 0 74</code></p>

<p>what is wrong in my second part of code please help me, Thanks!</p>