"And he came upon the place" (Genesis 28:11). The Divine Presence came and said to him: Jacob My son, twelve hours [of the night you will rest here] correspond to the twelve tribes that I am giving you, and twelve constellations are set in the firmament [corresponding] to the twelve stones of the pillar. And when Joseph was sold, Jacob wept and mourned for all those twenty-two years. He said: Woe is me, for perhaps I have become liable to punishment because I married two sisters, or perhaps I benefited from the property of Laban, or perhaps I benefited from the property of Shechem, and that covenant which the Holy One, blessed be He, made with me has been annulled. Immediately the mercy of the Holy One, blessed be He, was stirred, and He added to him seventeen years. From this they said: Whoever attains one good year close to his old age, it is a favorable sign for him. Jacob our father was in well-being for all those years that he was in Egypt; therefore Scripture reckons it for him as though he were in well-being all the days of his life.
Jacob's Twelve Stones and the Years Restored for His Mourning
Yalkut Shimoni on Torah 117:3
וַיִּפְגַּע בַּמָּקוֹם. בָּאת הַשְּׁכִינָה וְאָמְרָה לוֹ, יַעֲקֹב בְּנִי, שְׁתֵּים עֶשְׂרֵה שָׁעוֹת כְּנֶגֶד שְׁנֵים עָשָׂר שְׁבָטִים שֶׁאֲנִי נוֹתֵן לְךָ, שְׁתֵּים עֶשְׂרֵה מַזָּלוֹת בָּרָקִיעַ [כְּנֶגֶד] שְׁתֵּים עֶשְׂרֵה אַבְנֵי מַצֵּבָה. וּכְשֶׁנִמְכַּר יוֹסֵף הָיָה בּוֹכֶה וּמִתְאַבֵּל כָּל אוֹתָן עֶשְׂרִים וּשְׁתַּים שָׁנָה. אָמַר, אוֹי לִי שֶׁמָּא נִתְחַיָּבְתִּי שֶׁנָּשָׂאתִי שְׁתֵּי אֲחָיוֹת אוֹ שֶׁמָּא נֶהֱנֵיתִי מִמָמוֹנוֹ שֶׁל לָבָן, אוֹ שֶׁמָּא נֶהֱנֵיתִי מִמָּמוֹנָם שֶׁל שְׁכֶם, וּבָטְלָה אוֹתָהּ הַבְּרִית [שֶׁכָּרַת] לִי הַקָּדוֹשׁ בָּרוּךְ הוּא, מִיָּד נִתְגַּלְגְּלוּ רַחֲמָיו שֶׁל הַקָּדוֹשׁ בָּרוּךְ הוּא וְהוֹסִיף לוֹ שְׁבַע עֶשְׂרֵה שָׁנָה מִכָּאן אָמְרוּ, כָּל שֶׁהִשִּׂיגָתוֹ שָׁנָה אַחַת טוֹבָה סָמוּךְ לְזִקְנָתוֹ סִימָן יָפֶה לוֹ, יַעֲקֹב אָבִינוּ הָיָה בְּטוֹבָה כָּל אוֹתָן הַשָּׁנִים שֶׁהָיָה בְּמִצְרַיִם לְפִיכָךְ הֶעֱלָה עָלָיו הַכָּתוּב כְּאִילוּ הָיָה בְּטוֹבָה כָּל יְמֵי חַיָּיו.