[FLINK-1252] Add support for serializing Date and Enums in the Java API

These checks fail if `obj` is null. Better: use `instanceof` or add a null check