LongConverter class

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

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

Constructors

LongConverter()

Properties

hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited

Static Methods

toLong(dynamic value) → int
Converts value into long or returns 0 when conversion is not possible. [...]
toLongWithDefault(dynamic value, int defaultValue) → int
Converts value into integer or returns default when conversion is not possible. [...]
toNullableLong(dynamic value) → int
Converts value into long or returns null when conversion is not possible. [...]