I need to get the value of a field using reflection. It so happens that I am not always sure what the datatype of the field is. For that, and to avoid some code duplication
Try to convertValue by Jackson
ObjectMapper mapper = new ObjectMapper() Integer a = 1; Long b = mapper.convertValue(a, Long.class)