(9) باب رُؤْيَا أَهْلِ السُّجُونِ وَالْفَسَادِ وَالشِّرْكِ
Narrated Abu Huraira:
Allah's Messenger (ﷺ) said, "If I stayed in prison as long as Joseph stayed and then the messenger came, I would respond to his call (to go out of the prison) ."
Reference: Sahih al-Bukhari 6992
In-book reference: Book 91, Hadith 11
USC-MSA web (English) reference(deprecated numbering scheme): Vol. 9, Book 87, Hadith 121