日期:2014-05-17 浏览次数:20590 次
import java.sql.Timestamp;
public class TestBean {
public String name;
public Timestamp time;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Timestamp getTime() {
return time;
}
public void setTime(Timestamp time) {
this.time = time;
}
}
public static void testGson(){
String a = "{name='zhangsan',time='2012-11-01 12:20:23'}";
Gson gson = new Gson();
TestBean tb = new TestBean();
tb = gson.fromJson(a, TestBean.class);
System.out.println(tb.name);
System.out.println(tb.time);
}