Description

The NumberFormatGen Generator allows a referenced generated value to be formatted.

For example, a user wants to take a number like 1234.09 and do the following: 

  • show + or - sign
  • remove decimal point
  • pad left up to 10 places


The generated result would yield, +0000123409.


Parameters

The following parameters may be configured for the NumberFormatGen Generator. Items with an asterisk* are required. 

  • reference* - Defines the Attribute to reference. Note :The Attribute being referenced should use a Generator that processes a floating point number. Example: #{com.acme.User.id}

  • decimalFormat* - Defines the format for the decimal number in the generated result.  Examples:
    • Value|Pattern|Ouptut
    • 123456.789|###,###.###|123,456.789
    • 123456.789|###.##|123456.79
    • 124.78|000000.000|000123.780
    • 9.95|000.###|009.95
    • 0.95|##0.###|0.95

  • includeSign* - Determines whether to include the sign in the output value. The choices are: 
    • NEVER
    • ALWAYS
    • POSITIVE_ONLY
    • NEGATIVE_ONLY

  • includeDecimal* - Determines whether to include the decimal in the output value or not.

  • padLength* - If the value is greater than zero, it defines how many zeros should be padded to the left (e.g. if padLength = 10 then 120024 -> 0000120024).


Example 1: Remove Decimal Point from Randomly Generated Decimal Number

For this example, the NumberFormatGen Generator has been linked with the RandomDecimalGen Generator. The RandomDecimalGen Generator generates a random decimal number. This Generator is referenced by the NumberFormatGen Generator, which then removes the decimal point from the number.



RandomDecimalGen Generator Configuration:



Sample Output