regex date validation for yyyyMMdd

后端 未结 3 1867
隐瞒了意图╮
隐瞒了意图╮ 2021-01-15 05:32

I\'m looking for a regex string that will validate dates formatted as yyyyMMdd (no delimiters) and works for leap years. The closest thing I found so far only validates dat

3条回答
  •  时光说笑
    2021-01-15 06:16

    I thing using regex for this is almost impossible, due to the complex calculation required for leap years. Jon Skeet is right: use new SimpleDateFormat("yyyyMMdd") for this.

提交回复
热议问题