3

After upgrading to Firebase 3, I started recieving the following errors when serializing java.util.date:

W/ClassMapper: No setter/field for day found on class java.util.Date (fields/setters are case sensitive!)

W/ClassMapper: No setter/field for timezoneOffset found on class java.util.Date (fields/setters are case sensitive!)

Will they affect anything?

How can I avoid those warnings?

Community
  • 1
  • 1
CaptainNemo
  • 1,532
  • 2
  • 22
  • 45
  • You cannot serialize a `java.util.Date` object to the Firebase database. I doubt this was possible before either, although I never tested it. – Frank van Puffelen Jun 17 '16 at 21:05
  • it is working. Now as well as before. the only problem is that now it issues a warning. What is then your suggestion for serializing dates? – CaptainNemo Jun 17 '16 at 21:34
  • 1
    It's generally thought to be a good idea to use a primitive long or Long object to store the date as a unix timestamp, and convert it to a human-readable formatted date object on the client. – pontiac_ventura Jul 05 '16 at 03:33
  • Sounds like a very prudent design. I was hoping to have a generic cots/Open source solution available for such a standard demand. – CaptainNemo Jul 05 '16 at 07:56

1 Answers1

4

As stated here and here, Firebase doesn't use Jackson anymore and Date is not supported. Store it in a Long variable. You can add convenience getters/setters and mark them with @Exclude to suppress serialization.

Community
  • 1
  • 1
cybergen
  • 3,108
  • 1
  • 22
  • 30