  We prove that if $f:\mathbb{R}^n\to\mathbb{R}$ is convex and
$A\subset\mathbb{R}^n$ has finite measure, then for any $\varepsilon>0$ there
is a convex function $g:\mathbb{R}^n\to\mathbb{R}$ of class $C^{1,1}$ such that
$\mathcal{L}^n(\{x\in A:\, f(x)\neq g(x)\})<\varepsilon$. As an application we
deduce that if $W\subset\mathbb{R}^n$ is a compact convex body then, for every
$\varepsilon>0$, there exists a convex body $W_{\varepsilon}$ of class
$C^{1,1}$ such that $\mathcal{H}^{n-1}\left(\partial W\setminus \partial
W_{\varepsilon}\right)< \varepsilon$. We also show that if
$f:\mathbb{R}^n\to\mathbb{R}$ is a convex function and $f$ is not of class
$C^{1,1}_{\rm loc}$, then for any $\varepsilon>0$ there is a convex function
$g:\mathbb{R}^n\to\mathbb{R}$ of class $C^{1,1}_{\rm loc}$ such that
$\mathcal{L}^n(\{x\in \mathbb{R}^n:\, f(x)\neq g(x)\})<\varepsilon$ if and only
if $f$ is essentially coercive, meaning that
$\lim_{|x|\to\infty}f(x)-\ell(x)=\infty$ for some linear function $\ell$. A
consequence of this result is that, if $S$ is the boundary of some convex set
with nonempty interior (not necessarily bounded) in $\mathbb{R}^n$ and $S$ does
not contain any line, then for every $\varepsilon>0$ there exists a convex
hypersurface $S_{\varepsilon}$ of class $C^{1,1}_{\textrm{loc}}$ such that
$\mathcal{H}^{n-1}(S\setminus S_{\varepsilon})<\varepsilon$.
