TeradataDatePeriodParseDelegate { public static Object parse(String s) throws Exception { System.out.println("TeradataDatePeriodParseDelegate: parse: s: " + s); String[] periodParts = s.split(","); java.sql.Date F; java.sql.Date T; java.util.Date ParsedFrom; java.util.Date ParsedTo; try { F = java.sql.Date.valueOf(periodParts[0]); } catch (IllegalArgumentException iex) { java.util.Date ud = df.parse(periodParts[0]); F = new java.sql.Date(ud.getTime()); } try { T = java.sql.Date.valueOf(periodParts[1]); } catch (IllegalArgumentException iex) { java.util.Date ud = df.parse(periodParts[1]); T = new java.sql.Date(ud.getTime()); } Object[] data = { F, T }; return new TeradataDatePeriod(data); }  static Object parse(String s);  }
@Test public void parseTest() { String fromStr = "2012-11-11"; String toStr = "2014-06-02"; DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date fromDate = null; Date toDate = null; try { fromDate = dateFormat.parse(fromStr); toDate = dateFormat.parse(toStr); } catch (ParseException e) { throw new Error("TeradataDatePeriodTest: toStringTest: error parsing test input"); } Date[] range = {fromDate, toDate}; TeradataDatePeriod tp = new TeradataDatePeriod(range); TeradataDatePeriod tp2 = null; try { tp2 = (TeradataDatePeriod) TeradataDatePeriodParseDelegate.parse(fromStr + "," + toStr); } catch (Exception e) { throw new Error("During TeradataDatePeriodParseDelegate.parse(" + fromStr + "," + toStr + ")"); } assertTrue("Date period parse does not produce expected object", tp.equals(tp2)); }