Source:
public void extractAttributesFunctionExtension17() throws InterruptedException { log.info("ExtractAttributesFunctionExtensionTestCase5: " + "<int> time: extract (<string> unit ,<string> dateValue)"); SiddhiManager siddhiManager = new SiddhiManager(); String inStreamDefinition = "" + "define stream inputStream (symbol string,dateValue string," + "timestampInMilliseconds long);"; String query = ("@info(name = 'query1') " + "from inputStream " + "select symbol , time:extract('WEEK', dateValue) as WEEK "+ "insert into outputStream;"); String query2 = ("@info(name = 'query2') " + "from inputStream " + "select symbol , time:extract('WEEK', dateValue) as WEEK "+ "insert into outputStream2;"); ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query + query2); executionPlanRuntime.addCallback("query1", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); eventArrived = true; for (Event inEvent : inEvents) { count++; log.info("Event : " + count + ",WEEK : " + inEvent.getData(1)); } } }); executionPlanRuntime.addCallback("query2", new QueryCallback() { @Override public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { EventPrinter.print(timeStamp, inEvents, removeEvents); eventArrived = true; for (Event inEvent : inEvents) { count++; log.info("Event : " + count + ",WEEK : " + inEvent.getData(1)); } } }); InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); executionPlanRuntime.start(); inputHandler.send(new Object[]{"IBM", "2017-10-8 02:23:44.999", 1507401000000L}); Thread.sleep(100); Assert.assertEquals(2, count); Assert.assertTrue(eventArrived); executionPlanRuntime.shutdown(); }

Target:
public void extractAttributesFunctionExtension17() throws InterruptedException, ParseException { log.info("extractAttributesFunctionExtension17: " + "<int> time: extract (<string> unit ,<string> dateValue)"); SiddhiManager siddhiManager = new SiddhiManager(); FastDateFormat userSpecificFormat; userSpecificFormat = FastDateFormat.getInstance(TimeExtensionConstants.EXTENSION_TIME_DEFAULT_DATE_FORMAT); Date userSpecifiedDate = userSpecificFormat.parse("2017-10-8 02:23:44.999"); Calendar calendarEN = Calendar.getInstance(); calendarEN.setTime(userSpecifiedDate); final Integer valueEN = calendarEN.get(Calendar.WEEK_OF_YEAR); String inStreamDefinition = "" + "define stream inputStream (symbol string,dateValue string," + "timestampInMilliseconds long);"; String query = ("@info(name = 'query1') " + "from inputStream " + "select symbol , time:extract('WEEK', dateValue) as WEEK " + "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 inEvent : inEvents) { count++; log.info("Event : " + count + ",WEEK : " + inEvent.getData(1)); Assert.assertEquals(valueEN, inEvent.getData(1)); } } }); InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); executionPlanRuntime.start(); inputHandler.send(new Object[]{"IBM", "2017-10-8 02:23:44.999", 1507401000000L}); Thread.sleep(100); Assert.assertEquals(1, count); Assert.assertTrue(eventArrived); executionPlanRuntime.shutdown(); }