Github user cestella commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/231#discussion_r76414698
  
    --- Diff: 
metron-platform/metron-common/src/main/java/org/apache/metron/common/dsl/functions/DateFunctions.java
 ---
    @@ -114,17 +122,176 @@ public Object apply(List<Object> objects) {
           }
           if(dateObj != null && formatObj != null) {
             try {
    -          return getEpochTime(dateObj.toString()
    -                             , formatObj.toString()
    -                             , tzObj == 
null?Optional.empty():Optional.of(tzObj.toString())
    -                             );
    -        } catch (ExecutionException e) {
    -          return null;
    -        } catch (ParseException e) {
    +          Optional<String> tz = (tzObj == null) ? Optional.empty() : 
Optional.of(tzObj.toString());
    +          return getEpochTime(dateObj.toString(), formatObj.toString(), 
tz);
    +
    +        } catch (ExecutionException | ParseException e) {
               return null;
             }
           }
           return null;
         }
       }
    +
    +  /**
    +   * Stellar Function: DAY_OF_WEEK
    +   *
    +   * The numbered day within the week.  The first day of the week, Sunday, 
has a value of 1.
    +   */
    +  public static class DayOfWeek extends BaseStellarFunction {
    +    @Override
    +    public Object apply(List<Object> args) {
    +
    +      // expect epoch milliseconds
    +      Long epochMillis = ConversionUtils.convert(args.get(0), Long.class);
    +      if(epochMillis == null) {
    +        return null;
    +      }
    +
    +      // create a calendar
    +      Calendar calendar = Calendar.getInstance();
    +      calendar.setTimeInMillis(epochMillis);
    +
    +      return calendar.get(Calendar.DAY_OF_WEEK);
    +    }
    +  }
    +
    +  /**
    +   * Stellar Function: DAY_OF_MONTH
    +   *
    +   * The day within the month.  The first day within the month has a value 
of 1.
    +   */
    +  public static class DayOfMonth extends BaseStellarFunction {
    +    @Override
    +    public Object apply(List<Object> args) {
    +
    +      // expect epoch milliseconds
    +      Long epochMillis = ConversionUtils.convert(args.get(0), Long.class);
    --- End diff --
    
    args.get(0) null check, please.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to