You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metron.apache.org by justinleet <gi...@git.apache.org> on 2017/07/13 14:51:44 UTC

[GitHub] metron issue #623: METRON-1003 ParserUtil parses dates incorrect

Github user justinleet commented on the issue:

    https://github.com/apache/metron/pull/623
  
    Thanks for submitting this, and thanks for being patient.  I took a look at what the method was doing, and it seems like we could probably just cleanup that method to something like:
    
    ```
      public static Long convertToEpoch(String m, String d, String ts,
                                        boolean adjust_timezone) throws ParseException {
        String day = StringUtils.leftPad(d.trim(), 2, '0');
        int year = Calendar.getInstance().get(Calendar.YEAR);
    
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMMddHH:mm:ss");
        if (adjust_timezone) {
          sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        }
        String conglomerated_ts = year + m.trim() + day + ts;
        Date date = sdf.parse(conglomerated_ts);
        return date.getTime();
      }
    ```
    At that point it gets rid of a bunch of the unnecessary `Calendar` stuff and pushed it to the `DateFormat`.  I'm also just generally unsure if this is the right place to even handle this function.  It hardly seems like it's useful for anything outside of Fireeye, given the formatting (but I don't know that we want to fix that here).  I'm inclined to just leave it here for now to get things working and clean up as follow-on.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---