ProductionRequest implements XmlConvertible { public Date[] getDates(String name, Date[] def) throws ProductionException { String text = getParameter(name, false); if (text == null) { return def; } String[] splits = text.trim().split("\\s"); Set<String> dateSet = new TreeSet<>(Arrays.asList(splits)); dateSet.remove(""); splits = dateSet.toArray(new String[dateSet.size()]); Arrays.sort(splits); Date[] dates = new Date[splits.length]; for (int i = 0; i < splits.length; i++) { dates[i] = parseDate(name, splits[i]); } return dates; } private  ProductionRequest();  ProductionRequest(String productionType,
                             String userName,
                             String... productionParametersKeyValuePairs);  ProductionRequest(String productionType,
                             String userName,
                             Map<String, String> productionParameters); String getProductionType(); String getUserName(); Map<String, String> getParameters(); String getParameter(String name, boolean mandatory); void setParameter(String key, String value); void ensureParameterSet(String name); static DateFormat getDateFormat(); String getString(String name); String getString(String name, String def); boolean getBoolean(String name); Boolean getBoolean(String name, Boolean def); int getInteger(String name); Integer getInteger(String name, Integer def); float getFloat(String name); Float getFloat(String name, Float def); double getDouble(String name); Double getDouble(String name, Double def); Date getDate(String name); Date getDate(String name, Date def); Date[] getDates(String name, Date[] def); Geometry getGeometry(String name); Geometry getGeometry(String name, Geometry def); String getProductionName(String defaultProductionName); boolean isAutoStaging(); String getStagingDirectory(String productionId); String getRegionName(); Geometry getRegionGeometry(); Geometry getRegionGeometry(Geometry defaultGeometry); List<DateRange> getDateRanges(); DateRange createFromMinMax(); String getXmlDecodedString(String name, String def); @Override String toXml(); static ProductionRequest fromXml(String xml); static final String DATE_PATTERN; static final DateFormat DATE_FORMAT; }
@Test public void testDateListParsing() throws ParseException, ProductionException { String dateList = "2002-03-19\n2003-02-28\t\t2002-05-21 " + "\n2002-11-13 2003-01-15 2002-04-28 2003-04-29\n\t 2003-04-30 "; ProductionRequest productionRequest = new ProductionRequest("L2", "ewa", "dateList", dateList); Date[] dates = productionRequest.getDates("dateList", null); assertNotNull(dates); assertEquals(8, dates.length); assertEquals(ProductionRequest.DATE_FORMAT.parse("2002-03-19"), dates[0]); assertEquals(ProductionRequest.DATE_FORMAT.parse("2002-04-28"), dates[1]); assertEquals(ProductionRequest.DATE_FORMAT.parse("2002-05-21"), dates[2]); assertEquals(ProductionRequest.DATE_FORMAT.parse("2002-11-13"), dates[3]); assertEquals(ProductionRequest.DATE_FORMAT.parse("2003-01-15"), dates[4]); assertEquals(ProductionRequest.DATE_FORMAT.parse("2003-02-28"), dates[5]); assertEquals(ProductionRequest.DATE_FORMAT.parse("2003-04-29"), dates[6]); assertEquals(ProductionRequest.DATE_FORMAT.parse("2003-04-30"), dates[7]); }