Hi,
According to the "ExtractAttributesFunctionExtension.java" of Siddhi shows
that;
if (unit.equals(TimeExtensionConstants.EXTENSION_TIME_UNIT_YEAR)) {
> returnValue = cal.get(Calendar.YEAR);
>
> } else if (unit.equals(TimeExtensionConstants.EXTENSION_TIME_UNIT_MONTH)) {
> returnValue = (cal.get(Calendar.MONTH) + 1);
>
> } else if (unit.equals(TimeExtensionConstants.EXTENSION_TIME_UNIT_SECOND))
> {
> returnValue = cal.get(Calendar.SECOND);
>
> } else if (unit.equals(TimeExtensionConstants.EXTENSION_TIME_UNIT_MINUTE))
> {
> returnValue = cal.get(Calendar.MINUTE);
>
> }
>
> * else if (unit.equals(TimeExtensionConstants.EXTENSION_TIME_UNIT_HOUR))
> { returnValue = cal.get(Calendar.HOUR);*
> } else if (unit.equals(TimeExtensionConstants.EXTENSION_TIME_UNIT_DAY)) {
> returnValue = cal.get(Calendar.DAY_OF_MONTH);
>
> } else if (unit.equals(TimeExtensionConstants.EXTENSION_TIME_UNIT_WEEK)) {
> returnValue = cal.get(Calendar.WEEK_OF_YEAR);
>
> } else if
> (unit.equals(TimeExtensionConstants.EXTENSION_TIME_UNIT_QUARTER)) {
> returnValue = (cal.get(Calendar.MONTH) / 3) + 1;
> }
> return returnValue;
>
According to [1] Java Docs of GregorianCalendar, HOUR_OF_DAY should be used
to return 24H format and, it seems that Siddhi doesn't provide that option.
[1] http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#HOUR
On Tue, Sep 22, 2015 at 7:55 AM, Grainier Perera <[email protected]> wrote:
> Hi,
>
> I'm trying to extract 'hour' from a millisecond time stamp using the below
> method of Siddhi time extension which is mentioned on [1
> <https://docs.wso2.com/display/CEP400/Siddhi+Extensions#SiddhiExtensions-time>
> ].
>
> <string> extract(<long> timestampInMilliseconds,<string> unit)
>>
>
> My test cases as follows;
>
> 1. ts = 1442707210 : Sun 20 Sep 2015 05:30:10 AM IST GMT+5:30
> 2. ts = 1442750400 : Sun 20 Sep 2015 *05:30:00 PM* IST GMT+5:30
> 3. ts = 1442793630 : Mon 21 Sep 2015 05:30:30 AM IST GMT+5:30
>
> And result for time:extract( ts, 'hour' ) for each test case;
> 1. 5
> 2. *5*
> 3. 5
>
> Seems it is returning extracted hour value in 12h format. Is there a way
> to get the extracted hour value in 24h format?
>
> [1]
> https://docs.wso2.com/display/CEP400/Siddhi+Extensions#SiddhiExtensions-time
>
> Thanks,
> Grainier
> --
> Grainier Perera
> Software Engineer
> Mobile : +94716122384
> WSO2 Inc. | http://wso2.com
> lean.enterprise.middleware
>
--
Grainier Perera
Software Engineer
Mobile : +94716122384
WSO2 Inc. | http://wso2.com
lean.enterprise.middleware
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev