The force for a spring with displacement , spring constant k is (Hook's Law).
From Newton's law
The solution of the above equation is .
If the spring is moved away equilibrium position, it will move with displacement similar to , which is called simple Harmonic motion (SHM).
The following applet shows relation betweeb simple harmonic motion and spring motion.