Sayyiduna Ibn Abbas (may Allah be pleased with them both) narrates from the Prophet (peace and blessings be upon him) that the Messenger of Allah (peace and blessings be upon him) said, concerning the saying of Allah: "When you contract a debt for a fixed term, write it down" [Surah al-Baqarah: 282]: "The first dispute was the one Adam made with Allah, when Allah showed him his offspring. He saw a man whose forehead was shining and asked: O my Lord! Who is this? He said: This is your son Dawud. He asked: O my Lord! How long is his life? He said: 60 years. He said: O my Lord! Increase his life. He said: No, unless you add something to it from your own life. He asked: How long is my life? He said: A thousand years. Adam said: I have gifted forty of them to him. Allah wrote it down and made the angels witnesses. When the time of Adam's death came and the angels arrived, he said: Forty years of my life remain. They said: You gifted them to your son Dawud. He said: I have not gifted anything. Allah brought out what was written, and the angels testified."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الشهادات / 20518