pip_services3_commons.convert.LongConverter module

pip_services3_commons.convert.LongConverter

Long conversion utilities

copyright

Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.

license

MIT, see LICENSE for more details.

class pip_services3_commons.convert.LongConverter.LongConverter

Bases: object

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

static to_long(value: Any)int

Converts value into long or returns 0 when conversion is not possible.

Parameters

value – the value to convert.

Returns

long value or 0 when conversion is not supported.

static to_long_with_default(value: Any, default_value: int)int

Converts value into integer or returns default when conversion is not possible.

Parameters
  • value – the value to convert.

  • default_value – the default value.

Returns

long value or default when conversion is not supported

static to_nullable_long(value: Any) → Optional[int, None]

Converts value into long or returns null when conversion is not possible.

Parameters

value – the value to convert.

Returns

long value or null when conversion is not supported.