FormatNumber

FormatNumber

Formats a number according to the specified format string. Either specify a sub-generator or run another generator using a Sequential before this one to provide a long number suitable to being formatted. This generator can be used to, e.g., easily generate and format telephone numbers if it is combined with a LongGenerator for providing a suitable number, splitIntoDigits=true and a format string which represents a phone number formatting rule. No other format specifiers then %d are allowed in the format string.

Attributes
Name Description Required Min Max Allowed Values
splitIntoDigits If splitIntoDigits is active, each digit can be formatted independently e.g.: number=1234567890 with format="(%d%d) %d%d%d%d %d%d%d%d" produces : "(12)3456 7890". In splitIntoDigits mode only the '%d' format specifier is allowed!
Default: false
no 0 1
  • true
  • false
  • 0
  • 1
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
locale Content type: String
Locale to use. A locale defines the formatting rules for numbers, e.g what symbol to use as the decimal point and the thousand separator.
Examples: 'en-US', 'en-GB'. 'de-DE'
'Default is: 'us'
no 0 1
  • ar
  • ar-AE
  • ar-BH
  • ar-DZ
  • ar-EG
  • ar-IQ
  • ar-JO
  • ar-KW
  • ar-LB
  • ar-LY
  • ar-MA
  • ar-OM
  • ar-QA
  • ar-SA
  • ar-SD
  • ar-SY
  • ar-TN
  • ar-YE
  • be
  • be-BY
  • bg
  • bg-BG
  • ca
  • ca-ES
  • cs
  • cs-CZ
  • da
  • da-DK
  • de
  • de-AT
  • de-CH
  • de-DE
  • de-GR
  • de-LU
  • el
  • el-CY
  • el-GR
  • en
  • en-AU
  • en-CA
  • en-GB
  • en-IE
  • en-IN
  • en-MT
  • en-NZ
  • en-PH
  • en-SG
  • en-US
  • en-ZA
  • es
  • es-AR
  • es-BO
  • es-CL
  • es-CO
  • es-CR
  • es-CU
  • es-DO
  • es-EC
  • es-ES
  • es-GT
  • es-HN
  • es-MX
  • es-NI
  • es-PA
  • es-PE
  • es-PR
  • es-PY
  • es-SV
  • es-US
  • es-UY
  • es-VE
  • et
  • et-EE
  • fi
  • fi-FI
  • fr
  • fr-BE
  • fr-CA
  • fr-CH
  • fr-FR
  • fr-LU
  • ga
  • ga-IE
  • he
  • he-IL
  • hi
  • hi-IN
  • hr
  • hr-HR
  • hu
  • hu-HU
  • id
  • id-ID
  • is
  • is-IS
  • it
  • it-CH
  • it-IT
  • ja
  • ja-JP
  • ja-JP-u-ca-japanese-x-lvariant-JP
  • ko
  • ko-KR
  • lt
  • lt-LT
  • lv
  • lv-LV
  • mk
  • mk-MK
  • ms
  • ms-MY
  • mt
  • mt-MT
  • nl
  • nl-BE
  • nl-NL
  • nn-NO
  • no
  • no-NO
  • pl
  • pl-PL
  • pt
  • pt-BR
  • pt-PT
  • ro
  • ro-RO
  • ru
  • ru-RU
  • sk
  • sk-SK
  • sl
  • sl-SI
  • sq
  • sq-AL
  • sr
  • sr-BA
  • sr-CS
  • sr-Latn
  • sr-Latn-BA
  • sr-Latn-ME
  • sr-Latn-RS
  • sr-ME
  • sr-RS
  • sv
  • sv-SE
  • th
  • th-TH
  • th-TH-u-nu-thai-x-lvariant-TH
  • tr
  • tr-TR
  • uk
  • uk-UA
  • und
  • vi
  • vi-VN
  • zh
  • zh-CN
  • zh-HK
  • zh-SG
  • zh-TW
gen Value Generator for this field no 0 1
format Content type: String
Format a number "printf style" using format specifiers. e.g: number=461012 with format="%08d" produces: "00461012". This generator converts/casts any provided number to 'long'. To format a float/double number use the "FormatFloatingPoint" generator. If splitIntoDigits is active, each digit can be formatted independently e.g.: number=1234567890 with format="(%d%d) %d%d%d%d %d%d%d%d" produces : "(12)3456 7890". In splitIntoDigits mode only the '%d' format specifier is allowed!
Default: false
yes 1 1

Example

  1. Format Integer as Telephone Number

    Generatates random integers and formats them as nine digit telephone numbers including three digit area code.

    Schema config for Format Integer as Telephone Number
    <?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">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Format Integer as Telephone Number-->
          <!--
            Generatates random integers and formats them as nine digit telephone numbers including three digit area code.
          -->
          <field name="original" size="" type="NUMERIC">
            <gen_LongNumber>
              <min>10000000</min>
              <max>999999999</max>
            </gen_LongNumber>
          </field>
          <field name="format_telephone_number" size="" type="NUMERIC">
            <gen_FormatNumber splitIntoDigits="true">
              <format>(%d%d%d) %d%d%d%d%d%d</format>
              <gen_OtherFieldValue>
                <reference field="original"/>
              </gen_OtherFieldValue>
            </gen_FormatNumber>
          </field>
          </table>
    </schema>
    
    Output for Format Integer as Telephone Number
    583138136|(583) 138136
    334279070|(334) 279070
    71226877|(071) 226877
    770129114|(770) 129114
    934507311|(934) 507311
    469349306|(469) 349306
    775680605|(775) 680605
    679366284|(679) 366284
    487193806|(487) 193806
    625467284|(625) 467284
2.7-83fb0 | 2020-04-22