'How to formate or validate date in java like 20992012 or 12122022? [duplicate]

i have to validate date

yyyyMMdd or MMddyyyy or ddMMyyyy. 

if i pass input 20221224, ho to make this is valid? but how can i do this in regex or normal? Can we do this in regex?

How to identify whether this yyyyMMdd or MMddyyyy or ddMMyyyy?

Kindly share your inputs


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source