package com.kilfat.web.model.deserializer;

import com.fasterxml.jackson.databind.JsonNode;
import com.kilfat.config.ServiceConstants;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DeserializerHelper {
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat(ServiceConstants.DATE_FORMAT);

    public static JsonNode getFieldNode(JsonNode node, String field) {
        if (node.get(field) != null) {
            return node.get(field);
        }
        return null;
    }

    public static String getField(JsonNode node, String field) {
        if (node.get(field) != null) {
            return node.get(field).textValue();
        }
        return "";
    }

    public static Integer getIntegerField(JsonNode node, String field) {
        if (node.get(field) != null) {
            return node.get(field).intValue();
        }
        return null;
    }

    public static Long getLongField(JsonNode node, String field) {
        if (node.get(field) != null) {
            return node.get(field).longValue();
        }
        return null;
    }

    public static Date getDateField(JsonNode node, String field) {
        String dateAsString;
        if (node.get(field) == null) {
            return null;
        }
        dateAsString = node.get(field).textValue();
        try {
            return dateFormat.parse(dateAsString);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
}

@@ -1203,27 +1203,17 @@
     
-Stri
+lo
 ng date
-AsString
 ;%0A  
@@ -1241,24 +1241,61 @@
 eld) == null
+ %7C%7C node.get(field).isLong() == false
 ) %7B%0A        
@@ -1333,24 +1333,16 @@
     date
-AsString
  = node.
@@ -1348,33 +1348,30 @@
 .get(field).
-textValue
+asLong
 ();%0A        
@@ -1420,16 +1420,14 @@
 date
-AsString
+*1000L
 );%0A 

Change data parser, need to add unix timestamp support