Here you can find the source of longToOther(Object val, Class> dest)
public static Object longToOther(Object val, Class<?> dest)
//package com.java2s; /**/*from www .j ava 2 s . c o m*/ * * Copyright 2014 The Darks ORM Project (Liu lihua) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { public static Object longToOther(Object val, Class<?> dest) { if (val instanceof Long) { Long l = (Long) val; if (dest.equals(Integer.class) || dest.equals(int.class)) { return l.intValue(); } else if (dest.equals(Float.class) || dest.equals(float.class)) { return l.floatValue(); } else if (dest.equals(Double.class) || dest.equals(double.class)) { return l.doubleValue(); } else if (dest.equals(Byte.class) || dest.equals(byte.class)) { return l.byteValue(); } else if (dest.equals(Short.class) || dest.equals(short.class)) { return l.shortValue(); } else if (dest.equals(long.class)) { return l.longValue(); } else if (dest.equals(String.class)) { return String.valueOf(l); } } return val; } }