code: public static String getDigits(String value) {
  
      StringBuilder digits = new StringBuilder(value.length());
  
      for (char chr : value.toCharArray()) {
        if (Character.isDigit(chr)) {
          digits.append(chr);
        }
      }
  
      return digits.toString();
    }
docs: Extracts numbers from the String value.
  
  @param value the String value from which to extract numbers.
  @return only numbers from the String value.
  @throws NullPointerException if the String value is null.
  @see java.lang.Character#isDigit(char)