All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.onetwo.common.convert.ToLongConvertor Maven / Gradle / Ivy

There is a newer version: 5.2.7
Show newest version
package org.onetwo.common.convert;

public class ToLongConvertor extends AbstractTypeConvert {
	
	public ToLongConvertor() {
		super(0L);
	}

	@Override
	public Long doConvert(Object value, Class componentType) {
        Class c = value.getClass();
        if (c.getSuperclass() == Number.class)
            return ((Number) value).longValue();
        if (c == Boolean.class)
            return ((Boolean) value).booleanValue() ? 1L : 0L;
        if (c == Character.class){
            return (long)((Character) value).charValue();
        }
        return Long.parseLong(value.toString().trim());

	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy