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
Converting Integer to Long Very Simple and many ways to converting that Example 1
new Long(your_integer);
Example 2
Long.valueOf(your_integer);
Example 3
Long a = 12345L;
Example 4 If you already have the int typed as an Integer you can do this:
Integer y = 12; long x = y.longValue();