How to check Regular Expression for Timestamp in GWT?

后端 未结 3 1709
暖寄归人
暖寄归人 2021-01-06 20:28

What will be the regular expression for following Timestamp format

YYYY-MM-DD HH:mm:ss.S

YYYY-MM-DD HH:mm:ss.S AM/PM

YYYY-MM-DD HH:mm:ss.S AM/PM Z

YYYY-MM         


        
3条回答
  •  长情又很酷
    2021-01-06 21:14

    Just something simple as only describing the pattern like this:

    ^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}(?: [AP]M)?(?: [+-]\d{4})?$
    

    as any tentative of real date validation with a regex sounds inherently wrong.

    I got the uppercase Z as RFC822 timezone, regex needs changes to comply to TZDs or general textual time zones.

提交回复
热议问题