Skip to main content

    Units

    Package for converting and formatting units and numerical values.

    npm install @dynatrace-sdk/units

    Functions

    abbreviateNumber

    abbreviateNumber(input,scale,options): { formattedValue, postfix }

    Abbreviates large numbers into a shorter format with metric prefixes.

    Parameters

    NameTypeDescription
    input*requirednumberNumber to be abbreviated
    scale*requiredScale

    Scale configuration for abbreviation:

    • base: Base number for scaling (e.g., 1000 for metric, 1024 for binary)
    • levels: Array of prefix symbols (e.g., ['', 'k', 'M', 'G']) Default is decimal metric scale (k, M, G, T, etc.)
    options*requiredAdjustFractionDigitsOptions

    Formatting options:

    • minimumFractionDigits: Minimum decimal places
    • maximumFractionDigits: Maximum decimal places
    • roundingMode: How to handle rounding

    Returns

    Description

    Object containing:

    • formattedValue: The scaled numeric value as string
    • postfix: The metric prefix symbol

    Code example

    // Basic decimal abbreviation
    abbreviateNumber(1500)
    // Returns: { formattedValue: '2', postfix: 'k' }

    Code example

    // Binary (bytes) abbreviation
    abbreviateNumber(1048576, ExponentialOctalByteLevels)
    // Returns: { formattedValue: '1', postfix: 'MiB' }

    Code example

    // Custom fraction digits
    abbreviateNumber(1500000, ExponentialDecimalLevels, { maximumFractionDigits: 2 })
    // Returns: { formattedValue: '1.50', postfix: 'M' }

    adjustFractionDigits

    adjustFractionDigits(input,options?): string

    Formats a number with precise control over decimal places and handles very small values.

    Parameters

    NameTypeDescription
    input*requirednumberThe number to format
    optionsAdjustFractionDigitsOptions

    Formatting configuration:

    • minimumFractionDigits: Minimum decimal places (defaults to 0)
    • maximumFractionDigits: Maximum decimal places (defaults to minimumFractionDigits)
    • minimumSignificantDigits: Minimum significant digits (default: 1)
    • maximumSignificantDigits: Maximum significant digits (default: 21)
    • locale: Override default locale (e.g., 'en-US', 'de-DE')
    • useGrouping: Whether to use thousand separators

    Returns

    Description

    Formatted number string, with special handling for very small values:

    • Positive tiny values are prefixed with '< '
    • Negative tiny values are prefixed with '> '
    • Zero returns '0'

    Code example

    // Basic formatting
    adjustFractionDigits(1234.5678, { maximumFractionDigits: 2 })
    // Returns: '1,234.57'

    Code example

    // Format with custom locale
    adjustFractionDigits(1234.5, { locale: 'de-DE', maximumFractionDigits: 1 })
    // Returns: '1.234,5'

    Code example

    // Handle very small values
    adjustFractionDigits(0.0000001, { maximumFractionDigits: 3 })
    // Returns: '< 0.001'

    convert

    convert(input,from,to): number

    Converts a numeric value from one unit to another within the same measurement system

    Parameters

    NameTypeDescription
    input*requirednumberThe numeric value to convert
    from*requiredFromUnitSource unit (e.g., units.length.meter, units.time.second)
    to*requiredConvertibleTarget<FromUnit | ToUnit>Target unit for conversion (must be compatible with source unit)

    Returns

    Description
    Converted numeric value

    Throws

    Error TypeError Message
    undefinedError if units are incompatible (different measurement systems)

    Code example

    // Convert length
    import { convert, units } from "@dynatrace-sdk/units";
    convert(1500, units.length.meter, units.length.kilometer)
    // Returns: 1.5

    Code example

    // Convert temperature
    convert(32, units.temperature.degree_fahrenheit, units.temperature.degree_celsius)
    // Returns: 0

    Code example

    // Convert time
    convert(3600, units.time.second, units.time.hour)
    // Returns: 1

    format

    format(number,options?): string

    Converts and formats a numeric value using units and formatting options.

    Parameters

    NameTypeDescription
    number*requirednumberThe numeric value to format
    optionsFormatOptions<FromUnit | ToUnit>

    Formatting configuration options:

    • cascade: Cascades value down to specified unit depth (e.g., '1 km 500 m' for depth 2)
    • input: Source unit for conversion (e.g., units.length.meter)
    • output: Target unit for conversion (if not specified, only formatting is applied)
    • suffix: Custom suffix to override unit symbol
    • minimumFractionDigits: Minimum number of decimal places
    • maximumFractionDigits: Maximum number of decimal places (defaults to minimumFractionDigits or 0)
    • minimumSignificantDigits: Minimum significant digits (default: 1)
    • maximumSignificantDigits: Maximum significant digits (default: 21)
    • locale: Locale for number formatting (defaults to platform locale)
    • useGrouping: Whether to use thousand separators
    • abbreviate: Whether to shorten large numbers (e.g., 1.5K)

    Returns

    Description
    A formatted string with the number and its unit

    Code example

    // Format without units (abbreviation enabled by default)
    format(1500)
    // Returns: '2K'

    Code example

    // Format with unit conversion
    format(1500, {
    input: units.length.meter,
    maximumFractionDigits: 1
    })
    // Returns: '1.5 km'

    Code example

    // Format with unit cascading
    format(1500, {
    input: units.length.meter,
    cascade: 2
    })
    // Returns: '1 km 500 m'

    formatCurrency

    formatCurrency(number,currency,options?): string

    Formats a number according to currency and locale conventions.

    Parameters

    NameTypeDescription
    number*requirednumberThe numeric value to format
    currency*requiredundefined | "CHF" | "AED" | "AFN" | "ALL" | "AMD" | "ANG" | "AOA" | "ARS" | "AUD" | "AWG" | "AZN" | "BAM" | "BBD" | "BDT" | "BGN" | "BHD" | "BIF" | "BMD" | "BND" | "BOB" | "BRL" | "BSD" | "BTN" | "BWP" | "BYN" | "BZD" | "CAD" | "CDF" | "CLP" | "CNY" | "COP" | "CRC" | "CUC" | "CUP" | "CVE" | "CZK" | "DJF" | "DKK" | "DOP" | "DZD" | "EGP" | "ERN" | "ETB" | "EUR" | "FJD" | "FKP" | "GBP" | "GEL" | "GHS" | "GIP" | "GMD" | "GNF" | "GTQ" | "GYD" | "HKD" | "HNL" | "HRK" | "HTG" | "HUF" | "IDR" | "ILS" | "INR" | "IQD" | "IRR" | "ISK" | "JMD" | "JOD" | "JPY" | "KES" | "KGS" | "KHR" | "KMF" | "KPW" | "KRW" | "KWD" | "KYD" | "KZT" | "LAK" | "LBP" | "LKR" | "LRD" | "LSL" | "LYD" | "MAD" | "MDL" | "MGA" | "MKD" | "MMK" | "MNT" | "MOP" | "MRU" | "MUR" | "MVR" | "MWK" | "MXN" | "MYR" | "MZN" | "NAD" | "NGN" | "NIO" | "NOK" | "NPR" | "NZD" | "OMR" | "PAB" | "PEN" | "PGK" | "PHP" | "PKR" | "PLN" | "PYG" | "QAR" | "RON" | "RSD" | "RUB" | "RWF" | "SAR" | "SBD" | "SCR" | "SDG" | "SEK" | "SGD" | "SHP" | "SLE" | "SLL" | "SOS" | "SRD" | "SSP" | "STN" | "SVC" | "SYP" | "SZL" | "THB" | "TJS" | "TMT" | "TND" | "TOP" | "TRY" | "TTD" | "TWD" | "TZS" | "UAH" | "UGX" | "USD" | "UYU" | "UZS" | "VES" | "VND" | "VUV" | "WST" | "XAF" | "XCD" | "XCG" | "XDR" | "XOF" | "XPF" | "XSU" | "YER" | "ZAR" | "ZMW" | "ZWL" |ISO 4217 currency code (e.g., 'USD', 'EUR')
    optionsFormatCurrencyOptions

    Currency formatting configuration:

    • locale: Override default locale (e.g., 'en-US', 'de-DE')
    • abbreviate: Whether to shorten large numbers (e.g., '$1.5K')
    • minimumFractionDigits: Minimum decimal places
    • maximumFractionDigits: Maximum decimal places
    • useGrouping: Whether to use thousand separators Additional options from Intl.NumberFormat are supported

    Returns

    Description
    Formatted currency string

    Code example

    // Format with default options
    formatCurrency(1500, 'USD')
    // Returns: '$1.50K'

    Code example

    // Format with custom locale and no abbreviation
    formatCurrency(1500, 'EUR', {
    locale: 'de-DE',
    abbreviate: false
    })
    // Returns: '1.500,00 €'

    Code example

    // Format large number with abbreviation
    formatCurrency(1500000, 'USD', { abbreviate: true })
    // Returns: '$1.50M'

    formatDate

    formatDate(input,options?): string

    Formats a date according to locale and timezone settings.

    Parameters

    NameTypeDescription
    input*requirednumber | Date

    The date to format, as either:

    • Number of milliseconds since UNIX epoch
    • JavaScript Date object
    optionsFormatDateOptions

    Date formatting configuration:

    • locale: Override default locale (e.g., 'en-US', 'de-DE')
    • timeZone: Timezone name (e.g., 'UTC', 'America/New_York')
    • dateStyle: Full date formatting style ('full', 'long', 'medium', 'short')
    • timeStyle: Time formatting style ('full', 'long', 'medium', 'short')
    • hour12: Whether to use 12-hour clock (true) or 24-hour clock (false) Additional options from Intl.DateTimeFormatOptions are supported

    Returns

    Description
    Formatted date string according to locale and options

    Code example

    // Format date with default locale and timezone
    formatDate(new Date())
    // Returns: '5/27/2025'

    Code example

    // Format with custom locale and timezone
    formatDate(new Date(), {
    locale: 'de-DE',
    timeZone: 'Europe/Berlin',
    dateStyle: 'full'
    })
    // Returns: 'Dienstag, 27. Mai 2025'

    Code example

    // Format timestamp with custom style
    formatDate(1621344000000, {
    dateStyle: 'short',
    timeStyle: 'short'
    })
    // Returns: '5/27/25, 2:30 PM'

    formatLong

    formatLong(value,options?): string

    Formats large numbers with precise decimal handling, useful for scientific or financial calculations.

    Parameters

    NameTypeDescription
    value*requiredstring | number | bigint

    The value to format. Accepts:

    • number: Regular JavaScript number
    • bigint: For values beyond Number.MAX_SAFE_INTEGER
    • string: Numeric string representation
    optionsFormatLong

    Formatting configuration:

    • locale: Override default locale (e.g., 'en-US', 'de-DE')
    • minimumFractionDigits: Minimum decimal places
    • maximumFractionDigits: Maximum decimal places
    • minimumSignificantDigits: Minimum significant digits
    • maximumSignificantDigits: Maximum significant digits
    • useGrouping: Whether to use thousand separators

    Returns

    Description
    Formatted number string with precise decimal handling

    Code example

    // Format large number
    formatLong('123456789.123456789')
    // Returns: '123,456,789.123'

    Code example

    // Format with custom locale and fraction digits
    formatLong(123456.789, {
    locale: 'de-DE',
    maximumFractionDigits: 2
    })
    // Returns: '123.456,79'

    Code example

    // Format BigInt value
    formatLong(BigInt('9007199254740991'))
    // Returns: '9,007,199,254,740,991'

    formatUnit

    formatUnit(unit): string

    Formats a unit into a human-readable string representation.

    Parameters

    NameTypeDescription
    unit*requiredFormattableUnitThe unit to format, consisting of group, index, and exponent values

    Returns

    Description
    Formatted unit string

    Code example

    // Format a simple unit
    formatUnit([{ group: 'meter', index: 3, exponent: 1 }])
    // Returns: 'km'

    Code example

    // Format a compound unit
    formatUnit([
    { group: 'meter', index: 0, exponent: 1 },
    { group: 'hour', index: 0, exponent: '–1' }
    ])
    // Returns: 'm/s'

    Code example

    // Format with exponents
    formatUnit([{ group: 'meter', index: 0, exponent: 2 }])
    // Returns: 'm^2'

    getFormatting

    getFormatting(number,options?): Formatting

    Converts and formats a number into its constituent parts for flexible display.

    Parameters

    NameTypeDescription
    number*requirednumberThe numeric value to format
    optionsFormatOptions<FromUnit | ToUnit>

    Formatting configuration options:

    • cascade: Cascades value down to specified unit depth (e.g., '1 km 500 m' for depth 2)
    • input: Source unit for conversion (e.g., units.length.meter)
    • output: Target unit for conversion
    • suffix: Custom suffix to override unit symbol
    • minimumFractionDigits: Minimum number of decimal places
    • maximumFractionDigits: Maximum number of decimal places
    • minimumSignificantDigits: Minimum significant digits (default: 1)
    • maximumSignificantDigits: Maximum significant digits (default: 21)
    • locale: Locale for number formatting
    • useGrouping: Whether to use thousand separators
    • abbreviate: Whether to shorten large numbers (e.g., 1.5K)

    Returns

    Description

    An array of formatting parts, where each part contains:

    • separator: The spacing between value and symbol
    • symbol: The unit symbol or suffix
    • symbolPrefix: Whether the symbol appears before the value
    • value: The formatted numeric string

    Code example

    // Format bytes with default options
    getFormatting(1500)
    // Returns: [{ value: '2K', symbol: '', separator: '', symbolPrefix: false }]

    Code example

    // Format with custom units and fraction digits
    getFormatting(1500, {
    input: units.length.meter,
    maximumFractionDigits: 2
    })
    // Returns: [{ value: '1.5', symbol: 'km', separator: ' ', symbolPrefix: false }]

    mapGrailUnit

    mapGrailUnit(grailUnit): GrailUnitEquivalency

    Maps a Grail unit string to its corresponding units system equivalent.

    Parameters

    NameTypeDescription
    grailUnit*requiredstringThe Grail unit string to convert (e.g., 'BytePerSecond')

    Returns

    Description

    Unit equivalency object containing:

    • unit: Corresponding units system unit
    • type: Type of measurement (e.g., 'data', 'time')
    • base: Base unit for the measurement type

    Code example

    // Map data transfer rate unit
    mapGrailUnit('BytePerSecond')
    // Returns: { 'namespace': 'datarate', 'unitName': 'Bps', 'unit': [ { 'group': 'byte_m', 'index': 0, 'exponent': 1 }, { 'group': 'second', 'index': 0, 'exponent': '–1' } ] }

    parseTime

    ⚠️ Deprecated Use the parseTimeAsTimeValue function instead

    parseTime(candidate?,relativeDate): null | TimeDetails

    Converts a string representation of time into a structured TimeDetails object.

    Parameters

    NameTypeDescription
    candidateDEPRECATEDnull | string

    Input string to parse. Supports:

    • ISO 8601 format (e.g., '2025-05-27T14:30:00Z')
    • Relative expressions (e.g., 'now-30m', 'now+1h')
    • Date formats (e.g., '2025-05-27', '14:30')
    • 'now' keyword
    relativeDateDEPRECATED*requirednumberReference timestamp for relative expressions (defaults to current time)

    Returns

    Description

    TimeDetails object containing:

    • normalized: Cleaned and standardized input string
    • date: JavaScript Date object
    • type: 'expression' for relative times or 'iso8601' for absolute times Returns null if parsing fails

    Code example

    // Parse ISO datetime
    parseTime('2025-05-27T14:30:00Z')
    // Returns: {
    // normalized: '2025-05-27T14:30:00Z',
    // date: Date('2025-05-27T14:30:00.000Z'),
    // type: 'iso8601'
    // }

    Code example

    // Parse relative time
    parseTime('now-30m')
    // Returns: {
    // normalized: 'now-30m',
    // date: [Date 30 minutes before current time],
    // type: 'expression'
    // }

    Code example

    // Parse date format
    parseTime('2025-05-27 14:30')
    // Returns: {
    // normalized: '2025-05-27T14:30:00Z',
    // date: Date('2025-05-27T14:30:00.000Z'),
    // type: 'iso8601'
    // }

    parseTimeAsTimeValue

    parseTimeAsTimeValue(candidate?,relativeDate?,precision?): TimeValue | null

    Converts various time string formats into a normalized TimeValue object.

    Parameters

    NameTypeDescription
    candidatenull | string

    Input string to parse. Supports:

    • ISO 8601 (e.g., '2025-05-27T14:30:00Z')
    • Relative expressions (e.g., 'now-30m', 'now+1h')
    • Date formats (e.g., '2025-05-27', '14:30')
    • 'now' keyword
    relativeDatenumberReference timestamp for relative expressions
    precision"day" | "minutes" | "seconds" | "milliseconds"

    Output precision level:

    • 'day': Date only
    • 'minutes': Up to minutes
    • 'seconds': Up to seconds
    • 'milliseconds': Up to milliseconds

    Returns

    Description

    TimeValue object containing:

    • type: 'expression' | 'iso8601'
    • value: Normalized input string
    • absoluteDate: Resolved ISO timestamp Returns null if parsing fails

    Code example

    // Parse ISO datetime
    parseTime('2025-05-27T14:30:00Z')
    // Returns: {
    // type: 'iso8601',
    // value: '2025-05-27T14:30:00Z',
    // absoluteDate: '2025-05-27T14:30:00Z'
    // }

    Code example

    // Parse relative time
    parseTime('now-30m')
    // Returns: {
    // type: 'expression',
    // value: 'now()-30m',
    // absoluteDate: [ISO string 30 minutes before now]
    // }

    variantNames

    variantNames(unit): VariantNames<U>

    Returns the names of all units to which the provided unit can be converted.

    Parameters

    NameTypeDescription
    unit*requiredUThe source unit to find convertible variants for (e.g., units.length.meter)

    Returns

    Description
    Array of unit names that are valid conversion targets

    Code example

    // Get all length unit names
    variantNames(units.length.meter)
    // Returns:
    // ['meter', 'kilometer', 'centimeter', 'millimeter', ...]

    Code example

    // Get temperature unit names
    variantNames(units.temperature.degree_celsius)
    // Returns:
    // ['degree_celsius', 'degree_fahrenheit', ...]

    variantUnits

    variantUnits(unit): VariantUnits<U>

    Returns all units to which the provided unit can be converted.

    Parameters

    NameTypeDescription
    unit*requiredUThe source unit to find convertible variants for (e.g., units.length.meter)

    Returns

    Description
    Array of unit objects that are valid conversion targets

    Code example

    // Get all length units
    variantUnits(units.length.meter)
    // Returns:
    // [
    // [{ 'group': 'meter', 'index': -15, 'exponent': 1 }],
    // [{ 'group': 'meter', 'index': 30, 'exponent': 1 }],
    // ...
    // ]

    Code example

    // Get convertible temperature units
    variantUnits(units.temperature.degree_celsius)
    // Returns:
    // [
    // [{ 'group': 'degree_celsius', 'index': 0, 'exponent': 1 }],
    // [{ 'group': 'degree_fahrenheit', 'index': 0, 'exponent': 1 }],
    // ...
    // ]

    Constants

    ExponentialDecimalLevels

    Abbreviation levels for decimal metric prefixes from kilo to quecto, 10^3, 10^6, ...

    Properites

    NameType
    base*requirednumber
    levels*requiredArray<string>

    ExponentialOctalBitLevels

    Abbreviation levels for bit binary prefixes from kilobit to quebibit, 2^10, 2^20, ...

    Properites

    NameType
    base*requirednumber
    levels*requiredArray<string>

    ExponentialOctalByteLevels

    Abbreviation levels for byte binary prefixes from kibibyte to quebibyte, 2^10, 2^20, ...

    Properites

    NameType
    base*requirednumber
    levels*requiredArray<string>

    timeframeTranslations

    Properites

    NameType
    M*required(intl: IntlShape, values: { offset, prefix, suffix }) => string
    d*required(intl: IntlShape, values: { offset, prefix, suffix }) => string
    full-day*required(intl: IntlShape) => string
    h*required(intl: IntlShape, values: { offset, prefix, suffix }) => string
    m*required(intl: IntlShape, values: { offset, prefix, suffix }) => string
    ms*required(intl: IntlShape, values: { offset, prefix, suffix }) => string
    now*required(intl: IntlShape) => string
    q*required(intl: IntlShape, values: { offset, prefix, suffix }) => string
    remaining-day*required(intl: IntlShape) => string
    roundDown-M*required(intl: IntlShape, values: { amount, prefix }) => string
    roundDown-d*required(intl: IntlShape, values: { amount, prefix }) => string
    roundDown-h*required(intl: IntlShape, values: { amount, prefix }) => string
    roundDown-m*required(intl: IntlShape, values: { amount, prefix }) => string
    roundDown-q*required(intl: IntlShape, values: { amount, prefix }) => string
    roundDown-s*required(intl: IntlShape, values: { amount, prefix }) => string
    roundDown-w*required(intl: IntlShape, values: { amount, prefix }) => string
    roundDown-y*required(intl: IntlShape, values: { amount, prefix }) => string
    s*required(intl: IntlShape, values: { offset, prefix, suffix }) => string
    to*required(intl: IntlShape) => string
    today*required(intl: IntlShape) => string
    tomorrow*required(intl: IntlShape) => string
    w*required(intl: IntlShape, values: { offset, prefix, suffix }) => string
    y*required(intl: IntlShape, values: { offset, prefix, suffix }) => string
    yesterday*required(intl: IntlShape) => string

    units

    Grouped collection of all the supported units

    Properites

    NameType
    acceleration*required{ foot_per_second_squared, meter_per_second_squared }
    amount*required{ mole, one }
    angle*required{ degree, milliradian, minute, radian, revolution, second }
    area*required{ square_attometer, square_centimeter, square_decimeter, square_femtometer, square_foot, square_inch, square_kilometer, square_meter, square_micrometer, square_mile, square_millimeter, square_nanometer, square_picometer, square_yard, square_yoctometer, square_zeptometer }
    currencyDEPRECATED*required{ aud, cad, chf, cny, eur, gbp, jpy, nzd, usd }
    data*required{ bit, bit_binary, byte, byte_binary, exabit, exabyte, exibit, exibyte, gibibit, gibibyte, gigabit, gigabyte, kibibit, kibibyte, kilobit, kilobyte, mebibit, mebibyte, megabit, megabyte, pebibit, pebibyte, petabit, petabyte, quebibit, quebibyte, quettabit, quettabyte, robibit, robibyte, ronnabit, ronnabyte, tebibit, tebibyte, terabit, terabyte, yobibit, yobibyte, yottabit, yottabyte, zebibit, zebibyte, zettabit, zettabyte }
    datarate*required{ Bph, Bpm, Bps, GBph, GBpm, GBps, Gbitph, Gbitpm, Gbitps, GiBph, GiBpm, GiBps, Gibitph, Gibitpm, Gibitps, MBph, MBpm, MBps, Mbitph, Mbitpm, Mbitps, MiBph, MiBpm, MiBps, Mibitph, Mibitpm, Mibitps, bitph, bitpm, bitps, kBph, kBpm, kBps, kbitph, kbitpm, kbitps, kiBph, kiBpm, kiBps, kibitph, kibitpm, kibitps }
    electricity*required{ ampere, attoampere, attocoulomb, attofarad, attohenry, attoohm, attosiemens, attotesla, attovolt, attowatt, attoweber, centiampere, centicoulomb, centifarad, centihenry, centiohm, centisiemens, centitesla, centivolt, centiwatt, centiweber, coulomb, decaampere, decacoulomb, decafarad, decahenry, decaohm, decasiemens, decatesla, decavolt, decawatt, decaweber, deciampere, decicoulomb, decifarad, decihenry, deciohm, decisiemens, decitesla, decivolt, deciwatt, deciweber, exaampere, exacoulomb, exafarad, exahenry, exaohm, exasiemens, exatesla, exavolt, exawatt, exaweber, farad, femtoampere, femtocoulomb, femtofarad, femtohenry, femtoohm, femtosiemens, femtotesla, femtovolt, femtowatt, femtoweber, gigaampere, gigacoulomb, gigafarad, gigahenry, gigaohm, gigasiemens, gigatesla, gigavolt, gigawatt, gigaweber, hectoampere, hectocoulomb, hectofarad, hectohenry, hectoohm, hectosiemens, hectotesla, hectovolt, hectowatt, hectoweber, henry, kiloampere, kilocoulomb, kilofarad, kilohenry, kiloohm, kilosiemens, kilotesla, kilovolt, kilowatt, kiloweber, megaampere, megacoulomb, megafarad, megahenry, megaohm, megasiemens, megatesla, megavolt, megawatt, megaweber, microampere, microcoulomb, microfarad, microhenry, microohm, microsiemens, microtesla, microvolt, microwatt, microweber, milliampere, millicoulomb, millifarad, millihenry, milliohm, millisiemens, millitesla, millivolt, milliwatt, milliweber, nanoampere, nanocoulomb, nanofarad, nanohenry, nanoohm, nanosiemens, nanotesla, nanovolt, nanowatt, nanoweber, ohm, petaampere, petacoulomb, petafarad, petahenry, petaohm, petasiemens, petatesla, petavolt, petawatt, petaweber, picoampere, picocoulomb, picofarad, picohenry, picoohm, picosiemens, picotesla, picovolt, picowatt, picoweber, quectoampere, quectocoulomb, quectofarad, quectohenry, quectoohm, quectosiemens, quectotesla, quectovolt, quectowatt, quectoweber, quettaampere, quettacoulomb, quettafarad, quettahenry, quettaohm, quettasiemens, quettatesla, quettavolt, quettawatt, quettaweber, ronnaampere, ronnacoulomb, ronnafarad, ronnahenry, ronnaohm, ronnasiemens, ronnatesla, ronnavolt, ronnawatt, ronnaweber, rontoampere, rontocoulomb, rontofarad, rontohenry, rontoohm, rontosiemens, rontotesla, rontovolt, rontowatt, rontoweber, siemens, teraampere, teracoulomb, terafarad, terahenry, teraohm, terasiemens, teratesla, teravolt, terawatt, teraweber, tesla, volt, watt, weber, yoctoampere, yoctocoulomb, yoctofarad, yoctohenry, yoctoohm, yoctosiemens, yoctotesla, yoctovolt, yoctowatt, yoctoweber, yottaampere, yottacoulomb, yottafarad, yottahenry, yottaohm, yottasiemens, yottatesla, yottavolt, yottawatt, yottaweber, zeptoampere, zeptocoulomb, zeptofarad, zeptohenry, zeptoohm, zeptosiemens, zeptotesla, zeptovolt, zeptowatt, zeptoweber, zettaampere, zettacoulomb, zettafarad, zettahenry, zettaohm, zettasiemens, zettatesla, zettavolt, zettawatt, zettaweber }
    energy*required{ attojoule, attowatt_hour, centijoule, centiwatt_hour, decajoule, decawatt_hour, decijoule, deciwatt_hour, exajoule, exawatt_hour, femtojoule, femtowatt_hour, gigajoule, gigawatt_hour, hectojoule, hectowatt_hour, joule, kilojoule, kilowatt_hour, megajoule, megawatt_hour, microjoule, microwatt_hour, millijoule, milliwatt_hour, nanojoule, nanowatt_hour, petajoule, petawatt_hour, picojoule, picowatt_hour, quectojoule, quectowatt_hour, quettajoule, quettawatt_hour, ronnajoule, ronnawatt_hour, rontojoule, rontowatt_hour, terajoule, terawatt_hour, watt_hour, yoctojoule, yoctowatt_hour, yottajoule, yottawatt_hour, zeptojoule, zeptowatt_hour, zettajoule, zettawatt_hour }
    force*required{ attonewton, centinewton, decanewton, decinewton, exanewton, femtonewton, giganewton, hectonewton, kilonewton, meganewton, micronewton, millinewton, nanonewton, newton, petanewton, piconewton, pound, quectonewton, quettanewton, ronnanewton, rontonewton, teranewton, yoctonewton, yottanewton, zeptonewton, zettanewton }
    frequency*required{ attohertz, centihertz, decahertz, decihertz, exahertz, femtohertz, gigahertz, hectohertz, hertz, kilohertz, megahertz, microhertz, millihertz, nanohertz, petahertz, picohertz, quectohertz, quettahertz, ronnahertz, rontohertz, terahertz, yoctohertz, yottahertz, zeptohertz, zettahertz }
    length*required{ astronomical_unit, attometer, centimeter, decameter, decimeter, exameter, femtometer, foot, gigameter, hectometer, inch, kilometer, lightyear, megameter, meter, micrometer, mile, millimeter, nanometer, petameter, picometer, quectometer, quettameter, ronnameter, rontometer, terameter, yard, yoctometer, yottameter, zeptometer, zettameter }
    level*required{ decibel_milliwatt }
    liquidDEPRECATED*required{ attoliter, attolitre, centiliter, centilitre, decaliter, decalitre, deciliter, decilitre, exaliter, exalitre, femtoliter, femtolitre, gigaliter, gigalitre, hectoliter, hectolitre, kiloliter, kilolitre, liter, litre, megaliter, megalitre, microliter, microlitre, milliliter, millilitre, nanoliter, nanolitre, petaliter, petalitre, picoliter, picolitre, quectoliter, quectolitre, quettaliter, quettalitre, ronnaliter, ronnalitre, rontoliter, rontolitre, teraliter, teralitre, yoctoliter, yoctolitre, yottaliter, yottalitre, zeptoliter, zeptolitre, zettaliter, zettalitre }
    load*required{ millisecond_per_minute, nanosecond_per_minute, second_per_minute }
    mass*required{ attogram, centigram, decagram, decigram, exagram, femtogram, gigagram, grain, gram, hectogram, kilogram, megagram, microgram, milligram, nanogram, ounce, petagram, picogram, pound, quectogram, quettagram, ronnagram, rontogram, teragram, tonne, yoctogram, yottagram, zeptogram, zettagram }
    percentage*required{ one, parts_per_billion, parts_per_million, parts_per_trillion, per_mille, percent, promille }
    physics*required{ attocandela, attogray, attolumen, attolux, attosievert, attosteradian, candela, centicandela, centigray, centilumen, centilux, centisievert, centisteradian, decacandela, decagray, decalumen, decalux, decasievert, decasteradian, decicandela, decigray, decilumen, decilux, decisievert, decisteradian, exacandela, exagray, exalumen, exalux, exasievert, exasteradian, femtocandela, femtogray, femtolumen, femtolux, femtosievert, femtosteradian, gigacandela, gigagray, gigalumen, gigalux, gigasievert, gigasteradian, gray, hectocandela, hectogray, hectolumen, hectolux, hectosievert, hectosteradian, kilocandela, kilogray, kilolumen, kilolux, kilosievert, kilosteradian, lumen, lux, megacandela, megagray, megalumen, megalux, megasievert, megasteradian, microcandela, microgray, microlumen, microlux, microsievert, microsteradian, millicandela, milligray, millilumen, millilux, millisievert, millisteradian, nanocandela, nanogray, nanolumen, nanolux, nanosievert, nanosteradian, petacandela, petagray, petalumen, petalux, petasievert, petasteradian, picocandela, picogray, picolumen, picolux, picosievert, picosteradian, quectocandela, quectogray, quectolumen, quectolux, quectosievert, quectosteradian, quettacandela, quettagray, quettalumen, quettalux, quettasievert, quettasteradian, ronnacandela, ronnagray, ronnalumen, ronnalux, ronnasievert, ronnasteradian, rontocandela, rontogray, rontolumen, rontolux, rontosievert, rontosteradian, sievert, steradian, teracandela, teragray, teralumen, teralux, terasievert, terasteradian, yoctocandela, yoctogray, yoctolumen, yoctolux, yoctosievert, yoctosteradian, yottacandela, yottagray, yottalumen, yottalux, yottasievert, yottasteradian, zeptocandela, zeptogray, zeptolumen, zeptolux, zeptosievert, zeptosteradian, zettacandela, zettagray, zettalumen, zettalux, zettasievert, zettasteradian }
    pressure*required{ attopascal, bar, centipascal, decapascal, decipascal, exapascal, femtopascal, gigapascal, hectopascal, kilopascal, megapascal, micropascal, millipascal, nanopascal, pascal, petapascal, picopascal, psi, quectopascal, quettapascal, ronnapascal, rontopascal, terapascal, yoctopascal, yottapascal, zeptopascal, zettapascal }
    ratio*required{ attobel, bel, centibel, decabel, decibel, exabel, femtobel, gigabel, hectobel, kilobel, megabel, microbel, millibel, nanobel, petabel, picobel, quectobel, quettabel, ronnabel, rontobel, terabel, yoctobel, yottabel, zeptobel, zettabel }
    temperature*required{ degree_celsius, degree_fahrenheit, degree_rankine, kelvin }
    time*required{ attosecond, centisecond, day, decasecond, decisecond, exasecond, femtosecond, gigasecond, hectosecond, hour, kilosecond, megasecond, microsecond, millisecond, minute, month, nanosecond, petasecond, picosecond, quectosecond, quettasecond, ronnasecond, rontosecond, second, terasecond, week, year, yoctosecond, yottasecond, zeptosecond, zettasecond }
    time_squared*required{ second_squared, square_second }
    unspecified*required{ core, count, count_per_hour, count_per_minute, count_per_request, count_per_second, gigapixel, megapixel, millicore, msu, none, pixel, ratio, state, unspecified }
    velocity*required{ kilometer_per_hour, meter_per_hour, meter_per_second, miles_per_hour }
    volume*required{ attoliter, attolitre, centiliter, centilitre, cubic_decimeter, cubic_foot, cubic_inch, cubic_meter, decaliter, decalitre, deciliter, decilitre, exaliter, exalitre, femtoliter, femtolitre, gigaliter, gigalitre, hectoliter, hectolitre, kiloliter, kilolitre, liter, litre, megaliter, megalitre, microliter, microlitre, milliliter, millilitre, nanoliter, nanolitre, petaliter, petalitre, picoliter, picolitre, quectoliter, quectolitre, quettaliter, quettalitre, ronnaliter, ronnalitre, rontoliter, rontolitre, teraliter, teralitre, yoctoliter, yoctolitre, yottaliter, yottalitre, zeptoliter, zeptolitre, zettaliter, zettalitre }

    Types

    AdjustFractionDigitsOptions

    Properties

    NameTypeDescription
    localestring | Array<string>The locale according to which the number will be adjusted.
    maximumFractionDigitsnumberMaximum number of decimal digits.
    maximumSignificantDigitsnumberMaximum number of significant digits. Default is 21
    minimumFractionDigitsnumberMinimum number of decimal digits.
    minimumSignificantDigitsnumberMinimum number of significant digits. Default is 1
    useGroupingbooleanWhether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.

    FormatCurrencyOptions

    Properties

    NameTypeDescription
    abbreviateboolean

    It will shorten the number to a shorter format. (e.g. input: 1500, output: 1.5k).

    localestring | Array<string>The locale according to which the number will be formatted.

    FormatDateOptions

    Interface that extends Intl.DateTimeFormatOptions to pass an optional property to overwrite the default locale. See MDN.

    Properties

    NameTypeDescription
    localestring | Array<string>The locale according to which the number will be formatted.

    FormatOptions

    Properties

    NameTypeDescription
    abbreviateboolean

    It will shorten the number to a shorter format. (e.g. input: 1500, output: 1.5k).

    cascadenumber

    Will search for the biggest unit within its group and cascade it down the the specified depth. The last number will get rounded to maximumFractionDigits. (e.g. format(1500, { input: units.length.meter, cascade: 2}), output: '1 km 500 m')).

    inputFromUnit

    If input unit is defined, it will convert it to the best fitting unit. (e.g. format(1500, { input: units.length.meter }), output: '1.5 km')).

    localestring | Array<string>

    The locale that will be used to format the number. By default it will use the platform locale specified by the user.

    maximumFractionDigitsnumber

    The amount of maximumFractionDigits points. See MDN. If minimumFractionDigits is passed, set to minimumFractionDigits by default. Otherwise set to 0 by default.

    maximumSignificantDigitsnumberMaximum number of significant digits. Default is 21
    minimumFractionDigitsnumber

    The amount of minimumFractionDigits points. See MDN.

    minimumSignificantDigitsnumberMinimum number of significant digits. Default is 1
    outputOutputUnit<UndefinedCoalescing<FromUnit | > | ToUnit>

    If not specified, the conversion is disabled (e.g. format(1500), output: 1.5K).

    suffixstringA custom suffix that overwrites the unit symbol.
    useGroupingboolean

    Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators See MDN

    Still have questions?
    Find answers in the Dynatrace Community