/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.text.DateFormat;  
import java.text.SimpleDateFormat;  
import java.util.Date;  
import java.util.Calendar;  

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
        Date x = parse("Oct 1, 1997, 12:00:00 AM", "MMM d, yyyy, hh:mm:ss a");
		System.out.println("X String: " + x); 
	}
    
    public static Date parse(String dateString, String dateFormat) {
	    SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
	    sdf.setLenient(false);
	    try {
	        return sdf.parse(dateString);
	    } catch (Exception e) {
			System.out.println("E???");
	        return null;
	    }
	}
}