Prophet Yusuf stayed in the prison for many years even when his innocence was proved, yet he was happy as he considered himself safe from the invitations for sin.
Once the Egyptian King (Pharaoh)had a dream. He saw that seven lean cows eat seven fat cows and that there are seven green as well as seven dry ears of corn. In the morning, he told the court about his dream and asked for the interpretation. None could interpret the dream. The ex-prisoner whose dream Yusuf (AS) had interpreted, remembered him and asked to be sent to the prison so he could talk to him.
“And the king ( of Egypt) said: ‘Verily, I saw (in a dream) seven fat cows, whom seven lean cows were devouring, and seven green ears of corn and (seven) others dry. O notables! explain to me my dream, if it be that you can interpret dreams. “
“They said:’Mixed up false dreams and we are not skilled in the interpretation of dreams.:
“Then the man who was released(one of the two who were in the prison), now at length remembered and said:’I will tell you its interpretation, so send me forth.”
“(he said):’O Yusuf! the man of truth! Explain to us (the dream) of seven fat cows whom seven lean ones were devouring and of seven green ears of corn and (seven) others dry, that I may return to the people and that they may know.”
“(Yusuf )said:’ For seven consecutive years, you shall sow as usual and tha (harvest) which you reap you shall leave it in the ears, (all) except a little of it which you may eat.”
“Then will come after that, seven hard (years) which will devour what you have laid by in advance for them,(all) except a little of which you have guarded(stored).”
“Then thereafter will come a year in which people will have abundant rain and in which they will press(wine and oil).” Sura: Yusuf
The king was so impressed with this interpretation that he asked Yusuf (AS) to become his minister.