BinningOp extends Operator { static ProductData.UTC parseStartDateUtc(String date) { try { if (date.matches("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}")) { return ProductData.UTC.parse(date, DATETIME_INPUT_PATTERN); } else { return ProductData.UTC.parse(date, DATE_INPUT_PATTERN); } } catch (ParseException e) { throw new OperatorException(String.format("Error while parsing start date parameter '%s': %s", date, e.getMessage())); } } BinningOp(); Geometry getRegion(); void setRegion(Geometry region); String getStartDateTime(); void setStartDateTime(String startDateTime); Double getPeriodDuration(); void setPeriodDuration(Double periodDuration); TimeFilterMethod getTimeFilterMethod(); void setTimeFilterMethod(TimeFilterMethod timeFilterMethod); Double getMinDataHour(); void setMinDataHour(Double minDataHour); int getNumRows(); void setNumRows(int numRows); Integer getSuperSampling(); void setSuperSampling(Integer superSampling); String getMaskExpr(); void setMaskExpr(String maskExpr); void setOutputFile(String outputFile); void setOutputType(String outputType); void setOutputFormat(String outputFormat); VariableConfig[] getVariableConfigs(); void setVariableConfigs(VariableConfig... variableConfigs); AggregatorConfig[] getAggregatorConfigs(); void setAggregatorConfigs(AggregatorConfig... aggregatorConfigs); CellProcessorConfig getPostProcessorConfig(); void setPostProcessorConfig(CellProcessorConfig postProcessorConfig); void setBinWriter(BinWriter binWriter); void setOutputTargetProduct(boolean outputTargetProduct); void setMetadataAggregatorName(String metadataAggregatorName); String getOutputFile(); void setPlanetaryGridClass(String planetaryGridClass); void setCompositingType(CompositingType compositingType); @Override void initialize(); @Override void dispose(); BinningConfig createConfig(); static final String DATE_INPUT_PATTERN; static final String DATETIME_INPUT_PATTERN; static final String DATETIME_OUTPUT_PATTERN; }
@Test public void testParseStartDateUtc() { ProductData.UTC utc = BinningOp.parseStartDateUtc("2012-05-22"); assertEquals("22-MAY-2012 00:00:00.000000", utc.format()); utc = BinningOp.parseStartDateUtc("2012-05-22 11:22:33"); assertEquals("22-MAY-2012 11:22:33.000000", utc.format()); }
@Test public void testParseDateUtc_errorCase() { try { BinningOp.parseStartDateUtc("yesterday evening"); fail("OperatorException expected"); } catch (OperatorException oe) { String expected = "Error while parsing start date parameter 'yesterday evening': Unparseable date: \"yesterday evening\""; assertEquals(expected, oe.getMessage()); } }