Source:
public void dateFormatFunctionExtension2() throws InterruptedException { log.info("DateFormatFunctionExtensionInvalidFormatTestCase"); SiddhiManager siddhiManager = new SiddhiManager(); String inStreamDefinition = "define stream inputStream (symbol string," + "dateValue string,sourceFormat string,timestampInMilliseconds long,targetFormat string);"; String query = ("@info(name = 'query1') from inputStream select symbol , " + "time:dateFormat(dateValue,targetFormat,sourceFormat) as formattedDate," + "time:dateFormat(timestampInMilliseconds," + "targetFormat) as formattedUnixDate insert into outputStream;"); ExecutionPlanRuntime executionPlanRuntime = siddhiManager .createExecutionPlanRuntime(inStreamDefinition + query); executionPlanRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); eventArrived = true; for(int cnt=0;cnt<inEvents.length;cnt++){ count++; log.info("Event : " + count + ",formattedDate : " + inEvents[cnt].getData(1) + "," + "formattedMillsDate : " + inEvents[cnt].getData(2)); } } }); InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); executionPlanRuntime.start(); inputHandler.send(new Object[] { "IBM", "2014:11-11 13:23:44", "yyyy-MM-dd HH:mm:ss", 1415692424000L, "ss" }); Thread.sleep(100); Assert.assertEquals(1, count); Assert.assertTrue(eventArrived); executionPlanRuntime.shutdown(); }

Target:
public void dateFormatFunctionExtension2() throws InterruptedException { log.info("DateFormatFunctionExtensionInvalidFormatTestCase"); SiddhiManager siddhiManager = new SiddhiManager(); String inStreamDefinition = "define stream inputStream (symbol string," + "dateValue string,sourceFormat string,timestampInMilliseconds long,targetFormat string);"; String query = ("@info(name = 'query1') from inputStream select symbol , " + "time:dateFormat(dateValue,targetFormat,sourceFormat) as formattedDate," + "time:dateFormat(timestampInMilliseconds," + "targetFormat) as formattedUnixDate insert into outputStream;"); ExecutionPlanRuntime executionPlanRuntime = siddhiManager .createExecutionPlanRuntime(inStreamDefinition + query); executionPlanRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); eventArrived = true; for (Event event : inEvents) { count++; if (count == 1) { Assert.assertEquals(null, event.getData(1)); Assert.assertEquals("2014-11-11", event.getData(2)); } if (count == 2) { Assert.assertEquals(null, event.getData(1)); Assert.assertEquals("2014-11-11", event.getData(2)); } } } }); InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); executionPlanRuntime.start(); inputHandler.send(new Object[]{"IBM", "2014:11-11 13:23:44", "yyyy-MM-dd HH:mm:ss", 1415692424000L, "yyyy-MM-dd"}); inputHandler.send(new Object[]{"IBM", "2014:12-11 13:23:44", "yyyy-MM-dd HH:mm:ss", 1415692424000L, "yyyy-MM-dd"}); Thread.sleep(100); Assert.assertEquals(2, count); Assert.assertTrue(eventArrived); executionPlanRuntime.shutdown(); }