Long ago, there lived a sufi mystic, who used to say everyday in his prayers - thank you god for all that you go on doing for me. How can I repay? I feel so grateful. Once he was traveling far and it happened that for continues three days, he was refused shelter by people around as they thought him to be heretics. He was not even given any food or water. For whole three days, he went on hungry and thirsty,even after three days of hunger and thirst, at night he was praying, "Thank you god. how can I repay you? I feel so grateful."One of his disciple who was traveling with him, saw this and said, "Master, it's time to say something!! just think for a moment.what are you thanking for? for three days, we have been hungry, thirsty, no shelter and in desert, at mercy of wild animals.so, for what you are being grateful for?"Sufi laughed and said, "You don't understand. if I haven't eaten or drank anything for three days, that this is what I must have needed for these three days!!god always gives to me whatsoever I need.this must be my need for time, otherwise he would not have given it to me. I am thankful for it.he always takes care of me. he doesn't bother with what I desire, he gives me what he feels is right.I am thanking him, no food, no water, no shelter for three days, open sky with stars in desert, sleeping in open and still n wild animals has attacked us..still you are sad. why are you sad? it must have been our real need..!" 
This is trust, joyful attitude. One should learn to trust god in every condition. 