Datetime Parsers
  • 13 Dec 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Datetime Parsers

  • Dark
    Light
  • PDF

Article summary

The datetime parser will load data from a column in a source data table and convert values into date / time representations before producing numeric or categorical variables within a collection.

It inherits attributes and behaviors from its parent: abstract parser - column.

The datetime parser is one of the only parsers which can produce both numeric or categorical variables, depending on the transform attribute value.

Therefore the datetime parser also inherits attributes from the numeric parser type.

Attribute - pattern

The pattern attribute is required. Its value will be a valid Java SimpledDateFormat pattern string.

{
  "parser_type": "datetime", 
  "column": "ccc1",
  
  // This will be designed to match the datetime strings 
  // in the source data column
  //
  "pattern": "dd/MM/yyyy",
  
  "transform": "timestamp",
  "collection": "collection_name",
  "variable": "variable_name"
}

Attribute - transform

The transform attribute is required.

{
  "parser_type": "datetime", 
  "column": "ccc1",
  "pattern": "dd/MM/yyyy",
  
  // There a wide variety of transforms -
  // some of them will produce numeric variables,
  // and others will produce categorical variables.
  //
  // Numeric variable producing transforms:
  // "timestamp" - a UTC timesamp in milliseconds
  // "timestamp-minutes" - a UTC timestamp rounded to minutes
  // "timestamp-days" - a UTC timestamp rounded to days
  // "seconds-elapsed" - input time values are relative to the start of an event
  // "age" - input time values are birth dates, will round to years
  // "year-numeric"
  // "month-numeric"
  // "week-of-year"
  // "week-of-month"
  // "day-of-year"
  // "day-of-month"
  // "day-of-week-numeric"
  // "hour-of-day"
  // "minute"
  // "second"
  //
  // Categorical variable producing transforms:
  // "year"
  // "month"
  // "month-year"
  // "year-month"
  // "quarter"
  // "quarter-year"
  // "year-quarter"
  // "day-of-week"
  // "year-month-day"
  // "hour-minute-second"
  // "hour-minute"
  //
  "transform": "timestamp",
  
  "collection": "collection_name",
  "variable": "variable_name"
}

Attribute - pattern_time_zone

The pattern_time_zone attribute is optional. It will default to the time zone at the current local of the Data Product engine. See Java TimeZone for options.

{
  "parser_type": "datetime", 
  "column": "ccc1",
  "pattern": "dd/MM/yyyy",
  "transform": "hour-minute-second",
  
  // This will be the time used for input values
  //
  "pattern_time_zone": "GMT+1:00"
  
  "collection": "collection_name"
}

Attribute - transform_time_zone

The transform_time_zone attribute is optional. It will default to the time zone at the current local of the Data Product engine. See Java TimeZone for options.

{
  "parser_type": "datetime", 
  "column": "ccc1",
  "pattern": "dd/MM/yyyy",
  "transform": "hour-minute-second",
  
  // This will be the time zone used for output values
  //
  "transform_time_zone": "GMT-8:00"
  
  "collection": "collection_name"
}

Was this article helpful?