FormatDateAsNumber

FormatDateAsNumber

Parses a date in string format to the long number representing the number of milliseconds since 1970/01/01. Either specify a sub-generator or run another generator using a Sequential before this one to provide a date matching the inputFormat input format.

Attributes
Name Description Required Min Max Allowed Values
name (Class)Name of this element. Used to identify plugin Class. Full name is required. Example: com.en.myPluginPackage.myPuginClass no 0 1
id Identification String of this element. May be used to uniquely identify a field within the children of an Element. no 0 1
Nodes
Name Description Required Min Max Allowed Values
inputFormat Content type: String
Date or time input format for 'startDate', 'endDate', 'historicalStartDate' and 'historicalEndDate'. Default format: yyyy-MM-dd HH:mm:ss. Format specification: http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
yes 1 1
gen Value Generator for this field no 0 1

Examples

  1. Convert Datetime to Timestamp (Milliseconds)

    Generates random datetimes between 1970-01-01 00:00:00 and 2000-01-01 00:00:00 and consequently converts it to timestamps, that is milliseconds since 1970-01-01 00:00:00. The generator uses the default time format which is yyyy-MM-dd hh:mm:ss.

    Schema config for Convert Datetime to Timestamp (Milliseconds)
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <seed>1234567890L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <table name="FORMAT_DATE_AS_NUMBER">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Convert Datetime to Timestamp (Milliseconds)-->
          <!--
            Generates random datetimes between 1970-01-01 00:00:00 and 2000-01-01 00:00:00 and consequently converts it to
            timestamps, that is milliseconds since 1970-01-01 00:00:00. The generator uses the default time format which is
            yyyy-MM-dd hh:mm:ss.
          -->
          <field name="datetime" size="" type="DATE">
            <gen_DateTime>
              <startDate>1970-01-01 00:00:00</startDate>
              <endDate>2000-01-01 00:00:00</endDate>
              <outputFormat>yyyy-MM-dd HH:mm:ss</outputFormat>
            </gen_DateTime>
          </field>
          <field name="date_to_timestamp" size="" type="NUMERIC">
            <gen_FormatDateAsNumber>
              <inputFormat>yyyy-MM-dd HH:mm:ss</inputFormat>
              <gen_OtherFieldValue>
                <reference field="datetime"/>
              </gen_OtherFieldValue>
            </gen_FormatDateAsNumber>
          </field>
          </table>
    </schema>
    
    Output for Convert Datetime to Timestamp (Milliseconds)
    1990-12-25 08:45:19|662114719000
    1970-11-30 10:08:54|28807734000
    1997-01-22 15:45:43|853947943000
    1980-11-19 03:12:08|343451528000
    1975-10-24 18:02:57|183405777000
    1990-12-25 08:45:19|662114719000
    1986-11-12 15:54:38|532194878000
    1980-11-19 03:12:08|343451528000
    1990-12-25 08:45:19|662114719000
    1980-11-19 03:12:08|343451528000
  2. Convert Date to Timestamp (Milliseconds)

    Generates random dates between 1970-01-01 and 2000-01-01 and consequently converts it to timestamps, that is milliseconds since 1970-01-01 00:00:00. The generator uses the following time format: yyyy-MM-dd.

    Schema config for Convert Date to Timestamp (Milliseconds)
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <seed>1234567890L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <table name="FORMAT_DATE_AS_NUMBER">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Convert Date to Timestamp (Milliseconds)-->
          <!--
            Generates random dates between 1970-01-01 and 2000-01-01 and consequently converts it to timestamps, that is
            milliseconds since 1970-01-01 00:00:00. The generator uses the following time format: yyyy-MM-dd.
          -->
          <field name="date" size="" type="DATE">
            <gen_DateTime>
              <startDate>1970-01-01</startDate>
              <endDate>2000-01-01</endDate>
              <inputFormat>yyyy-MM-dd</inputFormat>
              <outputFormat>yyyy-MM-dd</outputFormat>
            </gen_DateTime>
          </field>
          <field name="date_to_timestamp" size="" type="NUMERIC">
            <gen_FormatDateAsNumber>
              <inputFormat>yyyy-MM-dd</inputFormat>
              <gen_OtherFieldValue>
                <reference field="date"/>
              </gen_OtherFieldValue>
            </gen_FormatDateAsNumber>
          </field>
          </table>
    </schema>
    
    Output for Convert Date to Timestamp (Milliseconds)
    1982-11-29|407376000000
    1994-07-03|773193600000
    1982-11-29|407376000000
    1988-10-05|592012800000
    1988-10-05|592012800000
    1988-03-04|573436800000
    1974-08-22|146361600000
    1973-05-27|107308800000
    1980-10-04|339465600000
    1980-10-04|339465600000
2.7-83fb0 | 2020-04-22