public static long asLong(Object value) {
        if (value instanceof Number) {
            return ((Number) value).longValue();
        } else if (value instanceof Numeric) {
            return ((Numeric) value).asInteger();
        } else if (value instanceof Boolean) {
            return ((Boolean) value) ? 1L : 0L;
        } else if (value instanceof CharSequence) {
            try {
                return Long.parseLong(value.toString());
            } catch (NumberFormatException nfe) {
                throw new IncompatibleValueException("Unable to parse string \"" + Strings.escape(value.toString()) +
                                                     "\" to a long", nfe);
            }
        } else if (value instanceof Date) {
            // Return date timestamp.
            return ((Date) value).getTime();
        }
        throw new IncompatibleValueException("Unable to convert " + value.getClass().getSimpleName() + " to a long");

    }
public static long asLong ( Object value ) { if ( value instanceof Number ) { return ( ( Number ) value ) . longValue ( ) ; } else if ( value instanceof Numeric ) { return ( ( Numeric ) value ) . asInteger ( ) ; } else if ( value instanceof Boolean ) { return ( ( Boolean ) value ) ? 1L : 0L ; } else if ( value instanceof CharSequence ) { try { return Long . parseLong ( value . toString ( ) ) ; } catch ( NumberFormatException nfe ) { throw new IncompatibleValueException ( "Unable to parse string \"" + Strings . escape ( value . toString ( ) ) + "\" to a long" , nfe ) ; } } else if ( value instanceof Date ) { return ( ( Date ) value ) . getTime ( ) ; } throw new IncompatibleValueException ( "Unable to convert " + value . getClass ( ) . getSimpleName ( ) + " to a long" ) ; }
Convert the value to a long.

@param value The value instance.
@return The long value.