Can we do the same thing if we generate the Java classes from the avro IDL ?
I am thinking something along the lines of:
record Person {
string name;
@targetClass("java.util.Date")
long dateOfBirth;
@targetClass("java.util.Date")
long registrationDatetime;
}
On Sun, Nov 22, 2015 at 3:51 PM, Evan McClain <[email protected]> wrote:
> On Sun, Nov 22, 2015 at 03:00:25PM -0500, David Lauzon wrote:
> >
> > 300 million years is more than enough :-)
> > Is there a way to get this long to deserialize automatically to a Java
> > 7 compatible type, like java.util.Date ?
> > (I'm using a framework which currently has issues on JDK 8).
>
> If you are using reflection to encode POJOs as avro, it's easy enough to do
> with DateAsLongEncoding:
>
> @AvroEncode(using=DateAslongEncoding.class)
> Date someDate;
>
> See:
> https://avro.apache.org/docs/1.7.7/api/java/org/apache/avro/reflect/DateAsLongEncoding.html
>
> And it's fairly easy to write your own encoder for java 8 java.time.Instant
> when you can upgrade to java 8.
>
> --
> Evan McClain
> https://keybase.io/aeroevan
>