Returning a date format from an unknown format of

2019-02-23 03:34发布

Possible Duplicate:
Parse any date in Java

Suppose we have a string of date in a format (unknown to the user). Examples of acceptable dates that you can receive from a user:

  • yyyy-MM-dd/yy-MM-dd
  • yyyy/MM/dd/yy/MM/dd
  • dd/MM/yyyy/dd/MM/yy
  • MM/dd/yyyy/MM/dd/yy`

Is there a library that accept a date in a string and returns a date format that can be used by SimpleDateFormat or Joda Time?

Thanks

1条回答
三岁会撩人
2楼-- · 2019-02-23 04:19

As a simple solution: I will apply each date format on the provided input to get a Date object , then I print the Date object with the same date format. If the input and the output for a date format are the same the date format is a candidate.

查看更多
登录 后发表回答