Recent observations confirm that our universe is flat and consists of a dark energy component with negative pressure. This dark energy is responsible for the recent cosmic acceleration as well as determines the feature of future evolution of the universe. In this paper, we discuss the dark energy of the universe in the framework of scalar-tensor cosmology. In the very early universe, the gravitational scalar field $phi$ plays the roll of the inflaton field and drives the universe to expand exponentially. In this period the field $phi$ acts as a cosmological constant and dominates the energy budget, the equation of state (EoS) is $w=-1$. The universe exits from inflation gracefully and with no reheating. Afterwards, the field $phi$ appears as a cold dark matter and continues to dominate the energy budget, the universe expands according to 2/3 power law, the EoS is $w=0$. Eventually, by the epoch of $zsim O(1)$, the field $phi$ contributes a significant component of dark energy with negative pressure and accellerates the late universe. In the future the universe will expand acceleratedly according to $a(t)sim t^{1.31}$.