package com.jiuqi.mobile.core.service.db; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import com.jqmobile.core.orm.DBColumn; public class ReflectTest { public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException { Field[] fields=Student.class.getDeclaredFields(); for(Field f:fields){ Annotation[] an=f.getAnnotations(); for(Annotation a:an){ System.out.println(a.toString()); } } // String str="你好"; // String type="java.lang.String"; // Class c=Class.forName(type); // Object object=c.newInstance(); // if(object instanceof String){ // System.out.println((String)str); // } // System.out.println(new Date(1384496589000l).toLocaleString()); // System.out.println(new Date().getTime()); // System.out.println(object instanceof String); // System.out.println(String.class==c); // Timestamp ts=new Timestamp(1384420259541l); // System.out.println(ts.getTime()); // Date date=new Date(1384420259541l); // System.out.println(date.toLocaleString()); // Date date=new Date(1384420259541l); // System.out.println((java.sql.Date)date); // Class<ORMDBTable> c=ORMDBTable.class; // System.out.println(c.getName()); // System.out.println(c.getName().substring(c.getName().lastIndexOf(".")+1,c.getName().length()-1)+"-------------------"+c.getAnnotation(DBTable.class).name()); // System.out.println(c.getAnnotation(DBTable.class)==null); // Class<TestBean> c=TestBean.class; // Field[] fields=c.getDeclaredFields(); // System.out.println(fields.length); // for(Field f:fields){ // Annotation[] annotations=f.getAnnotations(); // System.out.println(f.getName()+"----------"+annotations.length); // for (Annotation a:annotations) { // // } // System.out.println(f.getAnnotations()); // if(f.getAnnotation(DBColumn.class).date()){ // System.out.println(f.getType()); // } // } } }