Példa

public static void main ( String[] args ) {
String strShort = "125-"; // Az ar_EG területi beállításban -125 helyett 125- használandó //$NON-NLS-1$
try {
System.out.println( Short.parseShort(strShort) );
} catch (Exception e) {
// NumberFormatException
e.printStackTrace();
System.out.println( e.getMessage() );
}
}

Megoldás
Használja ezt
  • 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());
}
}

Megoldás
Használjon ICU 2.6.1-et
  • 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());
}
}