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
seed Random number generator seed of this Element. Overrides default seeding behavior. no 0 1
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! 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
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!
yes 1 1
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
  • und
  • ar-AE
  • ar-JO
  • ar-SY
  • hr-HR
  • fr-BE
  • es-PA
  • mt-MT
  • es-VE
  • bg
  • zh-TW
  • it
  • ko
  • uk
  • lv
  • da-DK
  • es-PR
  • vi-VN
  • en-US
  • sr-ME
  • sv-SE
  • es-BO
  • en-SG
  • ar-BH
  • pt
  • ar-SA
  • sk
  • ar-YE
  • hi-IN
  • ga
  • en-MT
  • fi-FI
  • et
  • sv
  • cs
  • sr-Latn-BA
  • el
  • uk-UA
  • hu
  • fr-CH
  • id
  • es-AR
  • ar-EG
  • ja-JP-u-ca-japanese-x-lvariant-JP
  • es-SV
  • pt-BR
  • be
  • is-IS
  • cs-CZ
  • es
  • pl-PL
  • tr
  • ca-ES
  • sr-CS
  • ms-MY
  • hr
  • lt
  • es-ES
  • es-CO
  • bg-BG
  • sq
  • fr
  • ja
  • sr-BA
  • is
  • es-PY
  • de
  • es-EC
  • es-US
  • ar-SD
  • en
  • ro-RO
  • en-PH
  • ca
  • ar-TN
  • sr-Latn-ME
  • es-GT
  • sl
  • ko-KR
  • el-CY
  • es-MX
  • ru-RU
  • es-HN
  • zh-HK
  • nn-NO
  • hu-HU
  • th-TH
  • ar-IQ
  • es-CL
  • fi
  • ar-MA
  • ga-IE
  • mk
  • tr-TR
  • et-EE
  • ar-QA
  • sr-Latn
  • pt-PT
  • fr-LU
  • ar-OM
  • th
  • sq-AL
  • es-DO
  • es-CU
  • ar
  • ru
  • en-NZ
  • sr-RS
  • de-CH
  • es-UY
  • ms
  • el-GR
  • he-IL
  • en-ZA
  • th-TH-u-nu-thai-x-lvariant-TH
  • hi
  • fr-FR
  • de-AT
  • nl
  • no-NO
  • en-AU
  • vi
  • nl-NL
  • fr-CA
  • lv-LV
  • de-LU
  • es-CR
  • ar-KW
  • sr
  • ar-LY
  • mt
  • it-CH
  • da
  • de-DE
  • ar-DZ
  • sk-SK
  • lt-LT
  • it-IT
  • en-IE
  • zh-SG
  • ro
  • en-CA
  • nl-BE
  • no
  • pl
  • zh-CN
  • ja-JP
  • de-GR
  • sr-Latn-RS
  • he
  • en-IN
  • ar-LB
  • es-NI
  • zh
  • mk-MK
  • be-BY
  • sl-SI
  • es-PE
  • id-ID
  • en-GB
gen Value Generator for this field no 0 1
  • pdgf.generator.MarkovChainText
  • pdgf.generator.AsReferenceChoice
  • pdgf.generator.WeightedListItem
  • pdgf.generator.DetailFromDate
  • pdgf.generator.BuildList
  • pdgf.generator.InsertIntoString
  • pdgf.generator.UUID
  • pdgf.generator.Probability
  • pdgf.generator.RandomString
  • pdgf.generator.Sequential
  • pdgf.generator.ConvertNumberToString
  • pdgf.generator.WeightedSubListItem
  • pdgf.generator.RandomListItems
  • pdgf.generator.Email
  • pdgf.generator.ActionDeleteIsAlsoUpdate
  • pdgf.generator.DoubleNumber
  • pdgf.generator.Permutation
  • pdgf.generator.Switch
  • pdgf.generator.ReferenceValue
  • pdgf.generator.ForFormula
  • pdgf.generator.PrePostfix
  • pdgf.generator.StaticValue
  • pdgf.generator.Hash
  • pdgf.generator.Padding
  • pdgf.generator.FormatString
  • pdgf.generator.DateTime
  • pdgf.generator.Id
  • pdgf.generator.LastChoice
  • pdgf.generator.MaskString
  • pdgf.generator.Null
  • pdgf.generator.AddRandomSeconds
  • pdgf.generator.RandomStringInRange
  • pdgf.generator.Formula
  • pdgf.generator.AbstractDecimal
  • pdgf.generator.FormatFloatingPoint
  • pdgf.generator.OtherFieldValue
  • pdgf.generator.RandomSentence
  • pdgf.generator.FormatNumber
  • pdgf.generator.Template
  • pdgf.generator.BigBenchReview
  • pdgf.generator.UpperLowerCase
  • pdgf.generator.For
  • pdgf.generator.Relative
  • pdgf.generator.RandomUniqeString
  • pdgf.generator.PermutationReference
  • pdgf.generator.UpdateActionType
  • pdgf.generator.FormatNumberAsDate
  • pdgf.generator.OldReferenceGeneratorDeprecated
  • pdgf.generator.DictList
  • pdgf.generator.ExtendedFormula
  • pdgf.generator.FormatDateAsNumber
  • pdgf.generator.If
  • pdgf.generator.GlobalRowNumber
  • pdgf.generator.LongNumber
  • pdgf.generator.UnsafeDistinct

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.6_#1486_b758 | 2016-05-24