Some relevant passages from the book of Iyov (Job):
1:1 "There was a man in the land of Uz whose name was Job, and that man was sincere and upright, God-fearing and shunning evil."
1:8-9 "Now the Lord said to the Adversary, 'Have you paid attention to My servant Job? For there is none like him on earth, a sincere and upright man, God-fearing and shunning evil.'
And the Adversary answered the Lord and said, "Does Job fear God for nothing?"
1:11-12 "But now, stretch forth Your hand and touch all that he has, will he not blaspheme You to Your face?
Now the Lord said to the Adversary, 'Behold, all that he has is in your hands; only upon him do not stretch forth your hand.' Now the Adversary left the presence of the Lord."
7:20-21 "I have sinned; what do I do to You? O watcher of man, why have You made me as a mark for You, so that I have become a burden to myself?
Now why do You not forgive my transgression and remove my iniquity, for now I will lie on the dust; and You shall seek me but I am not here."
9:21 "I am blameless, but I do not know how to find rest; I despise my life."
23:10-13 "Because He knows the way that is with me; He has tested me that I will emerge like gold.
[I kept] the commandment of His lips and I do not remove [it]; more than my daily bread I kept the words of His mouth.
But He is One, and who will answer Him? [Therefore,] whatever His soul desires He does."
27:6 "I have maintained my righteousness, and I will not let it go; my heart will not reproach [me] because of my days."
31:1 "Now these three men ceased to answer Job because he considered himself righteous.
42:10 "Now the Lord returned Job's captivity when he prayed for his friends, and the Lord gave Job twice as much as he had had before."
According to Iyov 42:10, Job stopped suffering unfairly after he prayed for his friends - that is, supposing that "returning Job's captivity" means that. But, beyond that, there is no way to tell how long did Job suffer unfairly, right? I couldn't find anything in Iyov.