package com.tozny.sdk.internal;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;
import java.util.Date;

public class DateDeserializer extends JsonDeserializer<Date> {

    public Date deserialize(JsonParser jp, DeserializationContext context)
        throws IOException, JsonProcessingException {
        String value = jp.nextTextValue();
        Date created = null;
        if (value != null) {
            try {
                created = new Date(Long.parseLong((String) value) * 1000);
            }
            catch (NumberFormatException e) {
                throw context.instantiationException(Long.class, e);
            }
        }
        return created;
    }

}

@@ -127,24 +127,69 @@
 gException;%0A
+import com.fasterxml.jackson.core.JsonToken;%0A
 import com.f
@@ -552,100 +552,278 @@
     
-String value = jp.nextTextValue();%0A        Date created = null;%0A        if (
+long timestamp;%0A        JsonToken token = jp.getCurrentToken();%0A        if (token.equals(JsonToken.VALUE_NUMBER_INT)) %7B%0A            timestamp = jp.getLongValue();%0A        %7D%0A        else if (token.equals(JsonToken.VALUE_STRING)) %7B%0A            String 
 value 
-!
 = 
-null) %7B
+jp.getText();
 %0A   
@@ -857,64 +857,40 @@
     
-created = new Date(Long.parseLong((String) value) * 1000
+timestamp = Long.parseLong(value
 );%0A 
@@ -1053,22 +1053,204 @@
     
-return created
+else %7B%0A            throw context.wrongTokenException(jp, token, %22While parsing Date value, expected a number or a string containing a number.%22);%0A        %7D%0A        return new Date(timestamp * 1000)
 ;%0A  

Modify DateDeserializer to accept number value in addition to string value