Code refactoring for getDateTime().