I have a string representing a date, for example "2010.12.25"
. How can I control if it is of "yyyy.MM.dd" format? There is no need to check the validness of the date.
You have the Regex, in Groovy, you can just do:
boolean match = "2010.12.12" ==~ /\d{4}\.\d{2}\.\d{2}/
use SimpleDateFormat
to parse()
the string, handling the exception to decide if it is a valid date string. don't use regex to check a date. e.g.:
2010.30.40
2010.13.34
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With