Listen to the confidence that David had in God,
“I will wait for You, O You [my] Strength; for God is my defense. My God of mercy shall come to meet me; God shall let me see my desire on my enemies” (Psa 59:9-10).
If you want to be able to think as David did, keep reading the Psalms and seek the relationship with God that David had.