FormatNumberAsDate

FormatNumberAsDate

Prints a number representing the milliseconds since 1970/01/01 as a string according to the configured outputFormat string. The default output format string is yyyy-MM-dd HH:mm:ss. Either specify a sub-generator or run another generator using a Sequential before this one to provide a long number representing the desired point in time.

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
outputFormat Content type: String
Date or time output format. 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

Example

  1. Convert Long Number to Date

    Generates random long numbers and converts them to dates. The generates numbers are referenced from the sub-generator and interpreted as milliseconds from 1970-01-01 00:00:00.

    Schema config for Convert Long Number to Date
    <?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_NUMBER_AS_DATE">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Convert Long Number to Date-->
          <!--
            Generates random long numbers and converts them to dates. The generates numbers are referenced from the
            sub-generator and interpreted as milliseconds from 1970-01-01 00:00:00.
          -->
          <field name="number" size="" type="NUMERIC">
            <gen_LongNumber>
              <min>1</min>
              <max>1461186456999</max>
            </gen_LongNumber>
          </field>
          <field name="number_as_date" size="" type="DATE">
            <gen_FormatNumberAsDate>
              <outputFormat>yyyy-MM-dd HH:mm:ss</outputFormat>
              <gen_OtherFieldValue>
                <reference field="number"/>
              </gen_OtherFieldValue>
            </gen_FormatNumberAsDate>
          </field>
          </table>
    </schema>
    
    Output for Convert Long Number to Date
    92380292|1970-01-02 01:39:40
    183250474|1970-01-03 02:54:10
    653409450|1970-01-08 13:30:09
    56411120|1970-01-01 15:40:11
    32473364|1970-01-01 09:01:13
    721775878|1970-01-09 08:29:35
    171962442|1970-01-02 23:46:02
    601282033|1970-01-07 23:01:22
    325440044|1970-01-04 18:24:00
    211663723|1970-01-03 10:47:43
2.7-83fb0 | 2020-04-22