compare dates in String format

后端 未结 10 1376
时光说笑
时光说笑 2021-02-12 16:30

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

10条回答
  •  猫巷女王i
    2021-02-12 17:04

    Is it really necessary to convert them to date and compare?

    If you don't have to include timezones and can ensure that you always have this format the lexical order will work.

    Will I miss anything?

    You lose the flexibility

    Am I doing the right thing?

    That depends on the point of view. I use something similar in a specialized search-enginge (only for performance reasons). Usually I convert to Date and compare these objects.

提交回复
热议问题