The time spent by a quantum particle in a scattering event or a tunneling process (the traversal time) through a rectangular barrier is calculated from the viewpoint of the stochastic formulation of quantum mechanics. Comparison with previous results is also provided.