If you simply want to/from RGB conversion and don't care how I would suggest using java.awt.Color
int r = 255; //red
int g = 255; //green
int b = 255; //blue
int a = 255; //alpha
Color c = new Color(r,g,b,a);
The using the getRGB method and getRed, getBlue, getGreen methods
int RGB = c.getRGB();
int red = c.getRed();
int blue = c.getBlue();
int green = c.getGreen();
Alternatively you can construct a color object using the Color(r,g,b)
constructor, it will have default 255 alpha.
With bit operations (ARGB, 32 bit colorspace). Constructing the RGB color:
int alpha = 255;
int red = 128;
int green = 128;
int blue = 128;
int RGB = (alpha << 24);
RGB = RGB | (red << 16);
RGB = RGB | (green << 8);
RGB = RGB | (blue);
System.out.println(Integer.toBinaryString(RGB));
Out 11111111100000001000000010000000
Decoding is done as in the link in the comment.