Check the date

Report a typo

Write a program that uses regular expressions to check whether the input date is valid.
The input date can be in any of the two formats: yyyy-mm-dd or dd-mm-yyyy. The year must be 19yy or 20yy. - /. symbols can be used as splitters.

dd from 01 to 31

mm from 01 to 12


For a given string output Yes if this string is a valid date, otherwise output No.

Sample Input 1:

21/12/1999

Sample Output 1:

Yes
Write a program in Java 17
import java.util.*;

class Date {

public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
String date = scn.nextLine();
String dateRegex = //put your code
}
}
___

Create a free account to access the full topic