fyhack / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Please support java.util.Calendar by default #106

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a Class Customer with 
Customer {
 String name;
 Calendar timestamp;
}
2.  Try Serializing this class and you will get an exception for Calendar

3.
            Customer c = new Customer();
        c.setName("jjj sdss");
        c.setRegTime(Calendar.getInstance());
                Gson gson = new Gson();
        String json = gson.toJson(c);

What is the expected output? What do you see instead?
Calendar seems to be not supported

What version of the product are you using? On what operating system?

Please provide any additional information below.
java.lang.RuntimeException: Unable to invoke no-args constructor for class
java.util.Calendar. Register an InstanceCreator with Gson for this type may
fix this problem.

Can java.util.Calendar be supported by default ??? 

Original issue reported on code.google.com by njun...@gmail.com on 5 Mar 2009 at 8:01

GoogleCodeExporter commented 9 years ago
Fixed in r391 by serializing a calendar object to something like
{year:2009,month:2,dayOfMonth:11,hourOfDay:14,minute:29,second:23}

I wonder if there is a standard way of serializing a calendar object that we 
should
be using.

Original comment by inder123 on 11 Mar 2009 at 9:48

GoogleCodeExporter commented 9 years ago

Original comment by inder123 on 27 Mar 2009 at 7:38