Sharp continuity results for the short-time Fourier transform and for localization operators