public static int reverse_old(int x) {

    boolean neg = false;

    if (x < 0) {
      x *= -1;
      neg = true;
    }

    StringBuffer sb = new StringBuffer(String.valueOf(x));
    int left = 0;
    int right = sb.length() - 1;
    while (left < right) {
      char leftChar = sb.charAt(left);
      char rightChar = sb.charAt(right);
      sb.setCharAt(left, rightChar);
      sb.setCharAt(right, leftChar);
      left++;
      right--;
    }

    return neg ? Integer.parseInt("-" + sb.toString()) : Integer.parseInt(sb.toString());
  }