NumberFormatBuilder Class
Utility class that can be used to create a number format for NumberFormat.
- Inheritance:
- NumberFormatBuilder
Methods
Accounting(Int32, Boolean, Boolean, String, Boolean)
Creates an accounting number format.
public static string Accounting(int decimalPlaces, bool useThousandsSeparator = true, bool useParenthesesToDisplayNegativeValue = false, string currencySymbol = null, bool showCurrencySymbolToTheRightOfNumber = false)
Public Shared Function Accounting(decimalPlaces As Integer, useThousandsSeparator As Boolean = True, useParenthesesToDisplayNegativeValue As Boolean = False, currencySymbol As String = Nothing, showCurrencySymbolToTheRightOfNumber As Boolean = False) As String
Parameters
decimalPlaces
- Int32
Number of decimal places that should be displayed to the right of the decimal separator.
useThousandsSeparator
- Boolean
True if the thousands separator should be displayed, false otherwise. The default value is true.
useParenthesesToDisplayNegativeValue
- Boolean
True if negative value should be displayed using parentheses notation, false if minus sign (-) should be used. The default value is false.
currencySymbol
- String
The currency symbol. Null, if no currency symbol should be displayed. The default value is null.
showCurrencySymbolToTheRightOfNumber
- Boolean
True if the currency symbol should be displayed to the right of the number, false otherwise. The default value is false.
Returns
The created number format.
Currency(String, Int32, Boolean, Boolean, Boolean, Boolean)
Creates a currency number format.
public static string Currency(string currencySymbol, int decimalPlaces, bool useThousandsSeparator = true, bool useParenthesesToDisplayNegativeValue = false, bool showCurrencySymbolToTheRightOfNumber = false, bool showSpaceBetweenCurrencySymbolAndNumber = true)
Public Shared Function Currency(currencySymbol As String, decimalPlaces As Integer, useThousandsSeparator As Boolean = True, useParenthesesToDisplayNegativeValue As Boolean = False, showCurrencySymbolToTheRightOfNumber As Boolean = False, showSpaceBetweenCurrencySymbolAndNumber As Boolean = True) As String
Parameters
currencySymbol
- String
The currency symbol.
decimalPlaces
- Int32
Number of decimal places that should be displayed to the right of the decimal separator.
useThousandsSeparator
- Boolean
True if the thousands separator should be displayed, false otherwise. The default value is true.
useParenthesesToDisplayNegativeValue
- Boolean
True if negative value should be displayed using parentheses notation, false if minus sign (-) should be used. The default value is false.
showCurrencySymbolToTheRightOfNumber
- Boolean
True if the currency symbol should be displayed to the right of the number, false otherwise. The default value is false.
showSpaceBetweenCurrencySymbolAndNumber
- Boolean
True if space should be displayed between the currency symbol and the number. The default value is true.
Returns
The created number format.
DateTimeIso8061(Int32)
Creates date and time format according to the ISO 8061 standard.
public static string DateTimeIso8061(int decimalPlaces = 0)
Public Shared Function DateTimeIso8061(decimalPlaces As Integer = 0) As String
Parameters
decimalPlaces
- Int32
The number of decimal places that should be used to display a fraction of a second. The default value is 0.
Returns
The created number format.
FractionWithFittingDenominator(Int32, Boolean)
Creates a fraction number format with the denominator value that best fits the fraction part of the number.
public static string FractionWithFittingDenominator(int maxDenominatorDigits, bool displayAsPureFraction = false)
Public Shared Function FractionWithFittingDenominator(maxDenominatorDigits As Integer, displayAsPureFraction As Boolean = False) As String
Parameters
maxDenominatorDigits
- Int32
The maximum number of digits used to display the denominator of the fraction.
displayAsPureFraction
- Boolean
True to display the number as a single fraction without the integral part, false otherwise. For example, the number 1.25 will be displayed as "5/4" if the parameter is true and as "1 1/4" if the parameter is false. The default value is false.
Returns
The created number format.
FractionWithPreciseDenominator(Int32, Boolean)
Creates a fraction number format with the precise denominator value.
public static string FractionWithPreciseDenominator(int denominator, bool displayAsPureFraction = false)
Public Shared Function FractionWithPreciseDenominator(denominator As Integer, displayAsPureFraction As Boolean = False) As String
Parameters
denominator
- Int32
Denominator that will be used to display the fraction part of the number.
displayAsPureFraction
- Boolean
True to display the number as a single fraction without the integral part, false otherwise. For example, the number 1.25 will be displayed as "5/4" if the parameter is true and as "1 1/4" if the parameter is false. The default value is false.
Returns
The created number format.
IsDateTime(String)
Checks if the provide number format is date format.
public static bool IsDateTime(string numberFormat)
Public Shared Function IsDateTime(numberFormat As String) As Boolean
Parameters
numberFormat
- String
Returns
True, if number format is date format, false otherwise.
Number(Int32, Int32, Boolean, Boolean)
Creates a format for a number.
public static string Number(int decimalPlaces, int minDigits = 1, bool useThousandsSeparator = false, bool useParenthesesToDisplayNegativeValue = false)
Public Shared Function Number(decimalPlaces As Integer, minDigits As Integer = 1, useThousandsSeparator As Boolean = False, useParenthesesToDisplayNegativeValue As Boolean = False) As String
Parameters
decimalPlaces
- Int32
The number of decimal places that should be displayed to the right of the decimal separator.
minDigits
- Int32
The minimal number of digits that should be displayed to the left of the decimal separator. The default value is 1.
useThousandsSeparator
- Boolean
True if the thousands separator should be displayed, false otherwise. The default value is false.
useParenthesesToDisplayNegativeValue
- Boolean
True if negative value should be displayed using parentheses notation, false if minus sign (-) should be used instead. The default value is false.
Returns
The created number format.
Percentage(Int32)
Creates a percentage number format.
public static string Percentage(int decimalPlaces)
Public Shared Function Percentage(decimalPlaces As Integer) As String
Parameters
decimalPlaces
- Int32
The number of decimal places that should be displayed to the right of the decimal separator.
Returns
The created number format.
Scientific(Int32)
Creates a scientific number format.
public static string Scientific(int decimalPlaces)
Public Shared Function Scientific(decimalPlaces As Integer) As String
Parameters
decimalPlaces
- Int32
The number of decimal places that should be displayed to the right of the decimal separator.
Returns
The created number format.
Text()
Creates a text number format.
Returns
The created number format.