// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class FormatCheck {
    public static void main(String[] args) {
        System.out.println(match("06/10/2003"));
        System.out.println(match("10-06-2003"));
        System.out.println(match("16/34/4007"));
    }
    private final static DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
    private static boolean match(String ds) {
        try {
            return df.format(df.parse(ds)).equals(ds);
        } catch (ParseException e) {
            return false;
        }
    }
}
