I\'m getting two dates as String values and I wanted to check start time is earlier than the end time. I compare them as it is without converting them to date using Simple
It is not good practice and a code smell.
You lose semantic correct and readable code. (and extensibility, timezones, and the other right things, that already had been said)
You don't want to compare two String
s, you want to compare 2 Date
s - so just do this, compare two Date
objects.
If you create unit-tests and test your comparing method, you will never write a method that compares 2 "string"-dates correctly in every case, without converting them to dates.