Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DateTimeConverter

Converts arbitrary values into Date values using extended conversion rules:

  • Strings: converted using ISO time format
  • Numbers: converted using milliseconds since unix epoch

Example

let value1 = DateTimeConverter.toNullableDateTime("ABC"); // Result: null
let value2 = DateTimeConverter.toNullableDateTime("2018-01-01T11:30:00.0"); // Result: Date(2018,0,1,11,30)
let value3 = DateTimeConverter.toNullableDateTime(123); // Result: Date(123)

Hierarchy

  • DateTimeConverter

Index

Methods

Static toDateTime

  • toDateTime(value: any): Date
  • Converts value into Date or returns current date when conversion is not possible.

    see

    toDateTimeWithDefault

    Parameters

    • value: any

      the value to convert.

    Returns Date

    Date value or current date when conversion is not supported.

Static toDateTimeWithDefault

  • toDateTimeWithDefault(value: any, defaultValue?: Date): Date
  • Converts value into Date or returns default when conversion is not possible.

    see

    toNullableDateTime

    Parameters

    • value: any

      the value to convert.

    • Default value defaultValue: Date = null

      the default value.

    Returns Date

    Date value or default when conversion is not supported.

Static toNullableDateTime

  • toNullableDateTime(value: any): Date
  • Converts value into Date or returns null when conversion is not possible.

    Parameters

    • value: any

      the value to convert.

    Returns Date

    Date value or null when conversion is not supported.

Generated using TypeDoc