java.lang.NumberFormatException: For input string: "1.0" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:477) at java.lang.Integer.(Integer.java:609) at com.gpcsoft.eprocurement.mydesktop.seller.business.SellerDeskTopBusiness$OrderNoComparator.compare(SellerDeskTopBusiness.java:219) at java.util.Arrays.mergeSort(Arrays.java:1278) at java.util.Arrays.sort(Arrays.java:1219) at java.util.Collections.sort(Collections.java:155)
public class OrderNoComparator implements Comparator {public int compare(Object element1, Object element2) {try {Object tmpStr2=BeanUtilsEx.getProperty(element1, "orderNo");Object tmpStr1=BeanUtilsEx.getProperty(element1, "orderNo"); //取出來的是 Double類型.結果toString();變成 x.0.就報錯了return (new Integer(tmpStr2.toString())).compareTo(new Integer(tmpStr1.toString()));} catch (IllegalAccessException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (InvocationTargetException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (NoSuchMethodException e) {// TODO Auto-generated catch blocke.printStackTrace();}return 0;}}