Nonequilibrium critical dynamics of the two-dimensional XY model