This can be seen as nice, but is remarkable when looked closer. David's life was filled with every type of distraction to break apart his heart and ruin his peace. There are so many examples:
As a young boy, he was anointed king while Saul was still one on the throne. Then David won the heart of the people by killing David, succeeding in suicide missions given by Saul and doing heroic deeds like killing Goliath. Saul returned the favor by trying to have David killed, messing up his love life (he had promised his daughter to be David's wife), and trying to set the nation against him. Nevertheless, David gave peace (שלם) to the king by playing the harp for him, refrained from killing Saul when he had just cause and every opportunity as Saul was searching to kill him, promised to keep the seed of Saul alive (which in the time of kings is basically asking for eternal opposition), and revenged the death of Saul when it came. He never let the difficulty of the situation destroy the wholeness or peace (שלם) in his heart of Saul's anointing (
Even in his sin, as he repented he found ways of peace. Bathsheba became pregnant from their affair, and the son that came from it became deathly ill. David prayed, fasted, and did all before the LORD he could pleading for the LORD to save his son. When David's son died though, he picked himself and cleaned himself up. David knew that the LORD had made His choice and was at peace (שלם) with it. David did not let his punishment put him at odds against God, and did not even let the punishment push him to do evil. He did what he could to repent, and as the punishment came he immediately was at peace with it.
Then with the tragic story of Absalom, where his own son was trying to usurp him. David had every reason to be taken in rage or to absolutely give up. Yet he still was able to fight the war to retain Israel, while keeping his love for his son. A situation that would destroy the hearts of almost any man, his heart remained whole (שלם). And while many may say that this was the opposite of a peaceful heart, imagine the heart of our Father in Heaven when His son Lucifer fought against Him for the crown. God's heart would have been similar to David's, and a Godly whole (שלם).
This is all so moving to me because lately in my research I've been looking at the impact of cognitive dissonance. When people feel conflicting emotions and selfs, they often do whatever they can to rid it. A common man who was anointed king and had the current king unjustly try to murder him would quickly justify all retribution, because how could he remain loyal when everything else says he shouldn't? People also want to feel good about themselves, and so when a punishment so hard as David's son dying comes from the hand of God most would either blame God or just cease believing. David kept his belief and owned up to his actions. Even with Absalom, the roles of father and king would destroy most men, but David remained David.
Keeping that balance is not something we see in almost any man or woman today. Our very mortal natures fight against it. While of course David sinned in a way most of us will not even come close to approaching, we all can learn from David's heart which in almost all cases remained whole and in the type of peace God would have (שלם).