Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LongConverter

Converts arbitrary values into longs using extended conversion rules:

  • Strings are converted to floats, then to longs
  • DateTime: total number of milliseconds since unix epoсh
  • Boolean: 1 for true and 0 for false

Example

let value1 = LongConverter.toNullableLong("ABC"); // Result: null
let value2 = LongConverter.toNullableLong("123.456"); // Result: 123
let value3 = LongConverter.toNullableLong(true); // Result: 1
let value4 = LongConverter.toNullableLong(new Date()); // Result: current milliseconds

Hierarchy

  • LongConverter

Index

Methods

Static toLong

  • toLong(value: any): number
  • Converts value into long or returns 0 when conversion is not possible.

    see

    toLongWithDefault

    Parameters

    • value: any

      the value to convert.

    Returns number

    long value or 0 when conversion is not supported.

Static toLongWithDefault

  • toLongWithDefault(value: any, defaultValue: number): number
  • Converts value into integer or returns default when conversion is not possible.

    see

    toNullableLong

    Parameters

    • value: any

      the value to convert.

    • defaultValue: number

      the default value.

    Returns number

    long value or default when conversion is not supported

Static toNullableLong

  • toNullableLong(value: any): number
  • Converts value into long or returns null when conversion is not possible.

    Parameters

    • value: any

      the value to convert.

    Returns number

    long value or null when conversion is not supported.

Generated using TypeDoc