How do I parse a date string?



  • Avatar
    Kumar Saurabh

    It is a two step process - first I had to extract the date string from the log line using a parse operator. parseDate converts the String to a Date object and use toMillis to translate a date into millis. parseDate operator supports the full format supported by java as described (if the link does not work, just google for "java date formatter")

    * | parse "*-0700" as datestr

    | toMillis(parseDate(datestr, "yyyy-MM-dd HH:mm:ss,SSS")) as dateInMillis



  • Avatar
    Charlie Pye

    How would I do this with a date formatted as yyyy-MM-dd HH:mm:ss ?  Without milliseconds.

  • Avatar
    Christian Beedgen

    try this:

    | toMillis(parseDate(datestr, "yyyy-MM-dd HH:mm:ss")) as dateInMillis



Please sign in to leave a comment.