The best fasting in the eye of Allah is that of David, for he fasted for half of the age (he fasted on alternate days), and the best prayer in the eye of Allah, the Exalted and Majestic, is that of David (peace be upon him), for he slept for half of the night and then stood for prayer and then again slept. He prayed for one-third of the night after midnight. He (the narrator) said: I asked 'Amr b. Dinar whether 'Amr b. Aus said that he stood for prayer one-third of the night after midnight. He said: Yes.
أَنَّ النَّبِيَّ ﷺ قَالَ أَحَبُّ الصِّيَامِ إِلَى اللَّهِ صِيَامُ دَاوُدَ كَانَ يَصُومُ نِصْفَ الدَّهْرِ وَأَحَبُّ الصَّلاَةِ إِلَى اللَّهِ ﷻ صَلاَةُ دَاوُدَ عَلَيْهِ السَّلاَمُ كَانَ يَرْقُدُ شَطْرَ اللَّيْلِ ثُمَّ يَقُومُ ثُمَّ يَرْقُدُ آخِرَهُ يَقُومُ ثُلُثَ اللَّيْلِ بَعْدَ شَطْرِهِ قَالَ قُلْتُ لِعَمْرِو بْنِ دِينَارٍ أَعَمْرُو بْنُ أَوْسٍ كَانَ يَقُولُ يَقُومُ ثُلُثَ اللَّيْلِ بَعْدَ شَطْرِهِ قَالَ نَعَمْ