/**
* @author lautturi.com
* Java example: check if a date string is in the format dd/mm/yyyy
*/
import java.util.*;
public class Lautturi {
public static void main(String[] args) {
String date = "12/13/2020";
if (date.matches("([0-9]{2})/([0-9]{2})/([0-9]{4})")) { // [0-9]{2} 2 digits exactly
System.out.println("The format is dd/mm/yyyy ");
}
}
}
output:
The format is dd/mm/yyyy