Java: custom to byte conversions
<p>I am working with some low capacity module and I need to compress the data as much as possible. The data will look like this:</p>

<p>DeviceEvent:</p>

<ul>
<li>1 byte:

<ul>
<li>2 bits for status (00 each time)</li>
<li>6 bits for rgb color (3 x 2 bits)</li>
</ul></li>
<li>2 bytes: number of minutes from now to a certain datetime</li>
</ul>

<p>I need to create a constructor (preferably 2 constructors) for conversion from/to:</p>

<p>Event:</p>

<ul>
<li>byte[] color (rgb, colors will get simplified to only 64 available)</li>
<li>some datetime (but I will get the integer for difference in minutes and it will be small enough to fit in two bits)</li>
</ul>

<p>So basically I need:</p>

<ul>
<li>byte[3] color &lt;-> 1 byte status and color  </li>
<li>int minutes &lt;-> byte[2]
minutes</li>
</ul>

<p>I will be thankful for any help</p>