Let $X$ be a real random variable with c.d.f function $F$. Let $g$ be an increasing measurable real function and assume that $\mathbb{E}\left[g(X)\right]$ exists (and is finite).

What additional assumptions do I need on $g$ for the following equality to hold? $$ \mathbb{E}\left[g(X)\right] = - \int_{-\infty}^{0}{F(t) \ dg(t)} + g(0) + \int_{0}^{+\infty}{\left(1-F(t) \right) \ dg(t)} $$

I have seen people using these kind of equalities, but I have never seen a rigorous statement yet. So I would like to know when can I use this transformation, and furthermore I am looking for a reference I can cite when using it.

Thank you for your help.

Edit: Equality corrected thanks to Alexandre Eremenko's comments.