Przykład

public static void main (String[] args){
String strShort = "125-"; // 125- to -125 w ustawieniach narodowych ar_EG //$NON-NLS-1$
try {
System.out.println( Short.parseShort(strShort) );
}catch (Exception e){
// NumberFormatException
e.printStackTrace();
System.out.println( e.getMessage() );
}
}

Rozwiązanie
Użyj
  • java.text.NumberFormat.parse (java.lang.String)

public static void main(String[] args){
java.util.Locale loc = new Locale("ar", "AE"); //$NON-NLS-1$ //$NON-NLS-2$
String strShort = "125-"; //$NON-NLS-1$

try {
short data = java.text.NumberFormat.getNumberInstance(loc).parse(strShort).shortValue();
System.out.println(data);
}catch (Exception e){
System.out.println(e.toString());
}
}

Rozwiązanie
Należy użyć ICU 2.6.1
  • com.ibm.icu.text.NumberFormat.parse (java.lang.String)

public static void main(String[] args){
java.util.Locale loc = new Locale("ar", "AE"); //$NON-NLS-1$ //$NON-NLS-2$
String strShort = "125-"; //$NON-NLS-1$

try {
short data = com.ibm.icu.text.NumberFormat.getNumberInstance(loc).parse(strShort).shortValue();
System.out.println(data);
}catch (Exception e){
System.out.println(e.toString());
}
}