If you’re absolutely sure the values returned by getTime() fit safely within an int range (which is rare with timestamps), you could cast them.
But this is not recommended for general use:
messagesByDeviceType.sort((o1, o2) -> (int)(o1.getTime() - o2.getTime()));