Here you can find the source of toJavaTypes(Class> clazz, String value)
public static Object toJavaTypes(Class<?> clazz, String value)
//package com.java2s; //License from project: Apache License public class Main { public static Object toJavaTypes(Class<?> clazz, String value) { if (Boolean.class == clazz || boolean.class == clazz) return Boolean.parseBoolean(value); if (Byte.class == clazz || byte.class == clazz) return Byte.parseByte(value); if (Short.class == clazz || short.class == clazz) return Short.parseShort(value); if (Integer.class == clazz || int.class == clazz) return Integer.parseInt(value); if (Long.class == clazz || long.class == clazz) return Long.parseLong(value); if (Float.class == clazz || float.class == clazz) return Float.parseFloat(value); if (Double.class == clazz || double.class == clazz) return Double.parseDouble(value); if ((Character.class == clazz || char.class == clazz) && value.length() == 1) return value.charAt(0); return value; }//from w ww . j a v a 2s . c o m }