Velocity over time of a mass on the spring Imagine a spring with constant $ \mathrm{k = 2 \ N/m}$. A mass of $2 \ \mathrm{kg}$ is dropped on it. (Initial velocity $= 0$)
Letting $\mathrm{g = 10 \ m/s²}$ , we can calculate the max velocity of the mass will be $\mathrm{10 \ m/s}$ when the spring is compressed $\mathrm{10 \ m}$. (The spring can at max be compressed $\mathrm{20 \ m}$, which is irrevelant to our question for now)
My question is, how can we calculate the time it takes for the spring to be compressed that much and reach the maximum velocity?
 A: You have correctly identified the maximum velocity and the displacement for that velocity. To get the time, you will have to solve a second-order differential equation.

The system diagram is shown in the picture below. Note that positive acceleration $a$ is in the direction of the positive $x$ axis which is upwards, where $x$ is the displacement of the string. The spring is at rest for $x=0$.

If coordinate system origin was placed at a different position, e.g., at the lowest point of the spring, the differential equation would have an affine component. That is not a big problem, but it is better not to have affine components.
Newton's second law of motion for the above diagram is:
$$ma = k\Delta x - mg$$
where $\Delta x = 0 - x$. Since acceleration is second derivative of distance (displacement), the above equation can also be written as:
$$\frac{d^2}{dt^2} x(t) + \frac{k}{m} x(t) = -g$$
The solution to this second-order differential equation with initial conditions $x(0) = x_0$ and $\dot{x}(0) = \dot{x}_0$ is:
$$x(t) = -\frac{mg}{k} \bigl( 1 - \cos(\omega_0 t) \bigr) + x_0 \cos(\omega_0 t) + \frac{\dot{x}_0}{\omega_0} \sin(\omega_0 t), \qquad t \geq 0$$
where natural frequency is defined as
$$\omega_0 = \sqrt{\frac{k}{m}} \quad \text{[rad/s]}$$
Note that $x_0$ is initial displacement and $\dot{x}_0$ is initial velocity, which are both zero in your example.
The velocity $v$ is defined as first derivative of distance (displacement):
$$v(t) = \frac{d}{dt}x(t) = -\frac{g}{\omega_0} \sin(\omega_0 t) - x_0 \omega_0 \sin(\omega_0 t) + \dot{x}_0 \cos(\omega_0 t), \qquad t \geq 0$$

By taking into account that $x_0 = 0$ and $\dot{x}_0 = 0$ the above two equations are simplified into
$$x(t) = -\frac{mg}{k} \bigl( 1 - \cos(\omega_0 t) \bigr), \qquad v(t) = -\frac{g}{\omega_0} \sin(\omega_0 t)$$
It is obvious now that the absolute maximum velocity
$$v_\text{max} = \frac{g}{\omega_0} \quad \text{[m/s]}$$
occurs when $\omega_0 t = n \frac{\pi}{2}$ where $n$ is any positive odd integer. Therefore, the maximum velocity occurs at $t_\text{max} = n \frac{\pi}{2} \frac{1}{\omega_0}$ for which the spring displacement is $x_\text{max} = -\frac{mg}{k}$.
When you plug the OP's numbers it follows $v_\text{max} = 10\text{ m/s}$, $x_\text{max} = 10\text{ m}$, and $t_\text{max} = \frac{\pi}{2}\text{ s}$.
It should be noted that the mass will permanently oscillate on the spring since there is nothing in the system that will dissipate the energy.
