Dwarves sleep approximately every month and a half (6 weeks), and will sleep for 1-2 weeks. They prefer to sleep indoors, on a bed, in their own room, and the quality or roughness of the item or surface they are resting on will have an impact on their happiness when they awaken. The restfulness of their sleep also has an impact on their happiness, and depends upon where they are sleeping and whether or not there is any noise reaching them.
A sleeping dwarf flashes between their standard icon and
After the dwarven economy starts, dwarves may randomly choose to sleep in barracks instead of their bedroom, even if there are no beds in the barracks - this does not seem to result in any unhappy thoughts.