Sharp criterion of global existence for nonlinear Schrödinger equation with a harmonic potential