Mega Code Archive

 
Categories / Java Tutorial / Regular Expressions
 

Date format consists of one or two digits followed by a hyphen, followed by one or two digits, followed by a hypen, fo

public class MainClass {   public static void main(String args[]) {     String date = "12-12-1212";     String datePattern = "\\d{1,2}-\\d{1,2}-\\d{4}";     System.out.println(date.matches(datePattern));   } }