check the format of date string in java

check the format of date string in java
r‮e‬fer to:lautturi.com
/**
 * @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
Created Time:2017-10-06 11:25:39  Author:lautturi