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
You can compare the date time without properly parsing it if and only if these 3 conditions are met:
The date time are always in the same format:
Jan
> April
, Wed
> Thu
).10:01
< 1:01
(:
has larger ASCII code than digits).The fields are ordered in descending order by the size of the unit (larger unit to the right, and smaller unit to the left). For example: YEAR-MONTH-DAY HOUR:MINUTE:SECOND.MILISECOND
They must be in the same time zone. The time zone information, if present, should have the same presentation (SGT
and UTC+8
are currently equivalent, but the String comparison won't know about this). Note that the above ambiguous condition "same time zone" is enough for comparing equal, but to compare larger/smaller, there must be no change in time zone happening between the 2 dates being compare.