Well, when we have a series RC-circuit we can use Laplace transform to analyse it in detail. Using Kirchoff law we can write:
$$\text{v}_\text{s}\left(t\right)=\text{v}_\text{R}\left(t\right)+\text{v}_\text{C}\left(t\right)\tag1$$
Using the relations of the voltage and current in a resitor and a capacitor we can rewrite equation $(1)$ as follows:
$$\text{v}_\text{s}'\left(t\right)=\text{i}_\text{R}'\left(t\right)\cdot\text{R}+\text{i}_\text{C}\left(t\right)\cdot\frac{1}{\text{C}}\tag2$$
Because it is a series circuit we know that the input current, $\text{i}_\text{in}\left(t\right)$, is the same as the current trough the resistor and the capacitor so we can write:
$$\text{v}_\text{s}'\left(t\right)=\text{i}_\text{in}'\left(t\right)\cdot\text{R}+\text{i}_\text{in}\left(t\right)\cdot\frac{1}{\text{C}}\tag3$$
Using the Laplace transform and assuming that the intial conditons are equal to $0$ we can write for equation $(3)$:
$$\text{s}\cdot\text{V}_\text{s}\left(\text{s}\right)=\text{s}\cdot\text{I}_\text{in}\left(\text{s}\right)\cdot\text{R}+\text{I}_\text{in}\left(\text{s}\right)\cdot\frac{1}{\text{C}}\space\Longleftrightarrow\space\text{I}_\text{in}\left(\text{s}\right)=\frac{\text{s}\cdot\text{V}_\text{s}\left(\text{s}\right)}{\text{s}\cdot\text{R}+\frac{1}{\text{C}}}\tag4$$
Assuming that the input voltage is a constant stabel DC-voltage ($\hat{\text{u}}$) gives for the supply voltage in the s-domain we get:
$$\text{V}_\text{s}\left(\text{s}\right)=\frac{\hat{\text{u}}}{\text{s}}\tag5$$
So, for the input current we get:
$$\text{I}_\text{in}\left(\text{s}\right)=\frac{\text{s}}{\text{s}\cdot\text{R}+\frac{1}{\text{C}}}\cdot\frac{\hat{\text{u}}}{\text{s}}=\frac{\hat{\text{u}}}{\text{s}\cdot\text{R}+\frac{1}{\text{C}}}\tag6$$
So, the voltage across the capacitor is given by:
$$\text{V}_\text{c}\left(\text{s}\right)=\frac{1}{\text{s}\cdot\text{C}}\cdot\frac{\hat{\text{u}}}{\text{s}\cdot\text{R}+\frac{1}{\text{C}}}\tag7$$
And for the voltage across the resistor we get:
$$\text{V}_\text{R}\left(\text{s}\right)=\text{R}\cdot\frac{\hat{\text{u}}}{\text{s}\cdot\text{R}+\frac{1}{\text{C}}}\tag8$$
So, for the energy we get:
- $$\text{e}_\text{C}\left(t\right)=\int_0^t\hat{\text{u}}\cdot\left(1-\exp\left(-\frac{\tau}{\text{RC}}\right)\right)\cdot\hat{\text{u}}\cdot\exp\left(-\frac{\tau}{\text{RC}}\right)\space\text{d}\tau=$$
$$\frac{\hat{\text{u}}^2\cdot\text{R}\cdot\text{C}}{2}\cdot\exp\left(-\frac{2t}{\text{RC}}\right)\cdot\left(\exp\left(\frac{t}{\text{RC}}\right)-1\right)\tag9$$
- $$\text{e}_\text{R}\left(t\right)=\int_0^t\text{R}\cdot\text{i}_\text{in}^2\left(\tau\right)\space\text{d}\tau=\text{R}\cdot\int_0^t\left(\hat{\text{u}}\cdot\exp\left(-\frac{\tau}{\text{RC}}\right)\right)^2\space\text{d}\tau=$$
$$\frac{\hat{\text{u}}^2\cdot\text{R}^2\cdot\text{C}}{2}\cdot\left(1-\exp\left(-\frac{2t}{\text{RC}}\right)\right)\tag{10}$$
And, as an example, let's say $\hat{\text{u}}=\text{R}=\text{C}=1$, than we can plot the solution:
Where the blue curve the energy in the capacitor is and the yellow curve is the energy in the resistor.