Psalm 30 is possibly David’s dedication to God for the future construction of the temple, since its title says: “Psalm singing in the dedication of the house”. Although it should be noted that the Psalm never mentions anything about the temple or its construction, which Solomon would build.
Regardless of who and what the psalm was written for, we must bear in mind that God is the one who turns our lament into dance and puts a praise on our lips.
There is a song based on this psalm that says as follows:
Thou hast turned my mourning into dancing for me;
Thou hast put off my sackcloth;
Thou hast turned my mourning into dancing for me,
And girded me with gladness;
To the end my glory may sing praise unto Thee,
And not be silent.
O Lord my God, I will give thanks unto Thee forever.