Long timestamp = Instant.now().toEpochMilli(); // fallback if (oTimestamp instanceof Integer) timestamp = (Integer) oTimestamp *1L; else if (oTimestamp instanceof Long) timestamp = (Long) oTimestamp * 1L;