private static Date cvtDate(String s, String fmt) {

	Date d = null;
	Calendar cal = null;
	int year  = 0;
	int month = 0;
	int day   = 0;

	// Organize logic for faster decisions, so most common
	// things up front...

	if(fmt == null || fmt.equals("YYYY-MM-DD")) {
	    year  = Utils.buildNumber(s, 0, 4);
	    month = Utils.buildNumber(s, 5, 2);
	    day   = Utils.buildNumber(s, 8, 2);

	} else if(fmt.equals("YYYYMMDD")) {
	    year  = Utils.buildNumber(s, 0, 4);
	    month = Utils.buildNumber(s, 4, 2);
	    day   = Utils.buildNumber(s, 6, 2);

	} else if(fmt.equals("YYMMDD")) {
	    year  = Utils.buildNumber(s, 0, 2);
	    if(year < 70) { 
		year += 2000; // 140203, 650203 -> 3-Feb-2014, 3-Feb-2065
	    } else { 
		year += 1900; // 700203, 960203 -> 3-Feb-1970, 3-Feb-1996
	    }
	    month = Utils.buildNumber(s, 2, 2);
	    day   = Utils.buildNumber(s, 4, 2);

	} else if(fmt.equals("YYYYMM")) { // 201405 becomes 1-May-2014
	    year  = Utils.buildNumber(s, 0, 4);
	    month = Utils.buildNumber(s, 4, 2);
	    day   = 1; // YOW!
	}

	if(year != 0) {
	    cal = Calendar.getInstance();
	    cal.clear();
	    cal.set( Calendar.YEAR,  year );
	    cal.set( Calendar.MONTH, month - 1);
	    cal.set( Calendar.DATE,  day ); 
	    d = cal.getTime();					
	    
	} else if(fmt != null && fmt.equals("ISO8601")) {
	    d = Utils.cvtISODateToDate(s);
	}

	return d;
    }