Once Satan appeared to him in the shape of a bird. David threw a dart at him. Instead of striking Satan, it glanced off and broke a wicker screen which hid Bath-sheba combing her hair. The sight of her aroused passion in the king. David realized his transgression, and for twenty-two years he was a penitent. Daily he wept a whole hour and ate his "bread with ashes." But he had to undergo still heavier penance. For a half-year he suffered with leprosy, and even the Sanhedrin, which usually was in close personal attendance upon him, had to leave him. He lived not only in physical, but also in spiritual isolation, for the Shekinah departed from him during that time.
Satan Appears as a Bird and David's Life Unravels
Legends of the Jews 4:54