So, if it's a double, it'd be easier translating it to 64-bits using long Double.doubleToLongBits(double value) and, converting it back using double Double.longBitsToDouble(long bits).
And, if its float values that you're converting to 32-bit values and then back again, you could use the functions, floatToIntBits(...) and intBitsToFloat(...).
But, for converting a double value to its 32 bits representation, you'd need a 2-step conversion, where you'd have to first convert it into a float value first:
double val = ...;
int bits = Float.floatToIntBits( (float) val );
And, with this, you convert it back:
int bits = ...;
double val = (double) Float.intBitsToFloat(bits);
Here's how the packing and unpacking directly to a buffer happens:
ByteArrayOutputStream baos = new ByteArrayOutputStream(20);
DataOutputStream dos = new DataOutputStream( ... );
dos.writeFloat( altitude );
dos.writeFloat( max_temperature );
dos.writeFloat( longitude );
dos.writeFloat( latitude );
byte data = baos.toByteArray();
But, you'll have to pick only some selected values that you convert to 32 bits, and figure out the ones you can truncate to occupy lesser space as all of this still generates a 20 bytes buffer (5 x 32-bit floats) and not a 12 bytes buffer.
And, for unpacking, you should be using a DataInputStream and readFloat(), like this:
ByteArrayInputStream bais = ...
DataInputStream dis = new DataInputStream(bais);
altitude = dis.readFloat();
max_temperature = dis.readFloat();