A finite-time condition for exponential dichotomy