title: How to understand that field is Number?
body: <p>I have the method which accepts <code>Field</code> and <code>Object</code></p>
  
  <pre><code>public String format(Field field, Object o) {....}
  </code></pre>
  
  <p>I want to know if field can be cast to number.</p>
  
  <p>I have noticed that if write something like this(for long primitive):</p>
  
  <pre><code>field.getType().isAssignableFrom(long.class)
  </code></pre>
  
  <p>returns <code>true</code></p>
  
  <p><strong>but</strong>   </p>
  
  <pre><code>field.getType().isAssignableFrom(Long.class)
  </code></pre>
  
  <p>returns <code>false</code></p>
  
  <p>and </p>
  
  <pre><code>field.getType().isAssignableFrom(Number.class)
  </code></pre>
  
  <p>returns <code>false</code> too</p>
  
  <hr>
  
  <p>Also</p>
  
  <pre><code>field.getType().cast(Number.class)
  </code></pre>
  
  <p>returns <code>ClassCastException</code></p>
  
  <p>Please help to write method which will return <code>true</code> if field is actually number(<code>int</code>, <code>long</code>, <code>byte</code>...,also all wrappers) and <code>false</code> in other cases.</p>
  
  <p>Is there simpler way than :</p>
  
  <pre><code>public String format(Field field, Object o) {
      field.setAccessible(true);
      Object value = null;
      try {
          value = field.get(o);
          if (value instanceof Number) {
              return field.get(o).toString();
          }
      } catch (IllegalAccessException e) {
          ....
      }
     ...
  }
  </code></pre>
  
  <p>?</p>