A vertical mass on a spring

If a mass is oscillating vertically at the end of a spring, you might think that we'd need to build in gravitational potential energy to handle the conservation of energy properly. You can do this if you want, measuring the elastic potential energy from the equilibrium length of the spring, but you don't have to.

If you measure the displacements of the spring about the equilibrium position with the mass attached to the spring, this is the point where the spring force cancels the force of gravity. Measured from this point, you just have to consider the kinetic energy and the elastic potential energy - don't worry about gravity.