public class Test { public static void main(String[] args) throws Exception { String resStr = Test.reverse(-123); System.out.println(Integer.parseInt(resStr)); }
public static String reverse(Integer value) throws Exception { String str = value.toString(); if (value >= 0) { StringBuffer sb = new StringBuffer(); sb.append(str); return sb.reverse().toString(); } else { StringBuffer sb = new StringBuffer(); sb.append(str.substring(1));