4.8 hours.
You can get this by setting up the equation:
x/8 + x/12 = 1
Where x is equal to the amount of hours spent working. In this equation x/4 would be the first painter. In 8 hours he would paint on room. x/12 would be the second painter. When you add them together using common denominators, you can find x.