Options
All
  • Public
  • Public/Protected
  • All
Menu

Class StringConverter

Converts arbitrary values into strings using extended conversion rules:

  • Numbers: are converted with '.' as decimal point
  • DateTime: using ISO format
  • Boolean: "true" for true and "false" for false
  • Arrays: as comma-separated list
  • Other objects: using toString() method

Example

let value1 = StringConverter.ToString(123.456); // Result: "123.456"
let value2 = StringConverter.ToString(true); // Result: "true"
let value3 = StringConverter.ToString(new Date(2018,0,1)); // Result: "2018-01-01T00:00:00.00"
let value4 = StringConverter.ToString([1,2,3]); // Result: "1,2,3"

Hierarchy

  • StringConverter

Index

Methods

Static toNullableString

  • toNullableString(value: any): string
  • Converts value into string or returns null when value is null.

    Parameters

    • value: any

      the value to convert.

    Returns string

    string value or null when value is null.

Static toString

  • toString(value: any): string
  • Converts value into string or returns "" when value is null.

    see

    toStringWithDefault

    Parameters

    • value: any

      the value to convert.

    Returns string

    string value or "" when value is null.

Static toStringWithDefault

  • toStringWithDefault(value: any, defaultValue: string): string
  • Converts value into string or returns default when value is null.

    see

    toNullableString

    Parameters

    • value: any

      the value to convert.

    • defaultValue: string

      the default value.

    Returns string

    string value or default when value is null.

Generated using TypeDoc