Parsing the DateTime format to get Format String

前端 未结 4 1523
慢半拍i
慢半拍i 2021-01-03 03:43

I would like to be able to get the format string from a DateTime string.

e.g.

"2012-12-08 15:00:00" => "yyyy-MM

4条回答
  •  自闭症患者
    2021-01-03 04:29

    You can have a set of predefined formats and parse the date and see if it passes, then you can get the string format you are looking for.

    Refer to the answer but its in java - How to get the given date string format(pattern) in java?

提交回复
热议问题