Name: yyT116575 Date: 06/14/2001
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
when pass a String contains Thai digits to
Double.valueOf()
Float.valueOf()
the NumberFormatException thrown:
Exception in thread "main" java.lang.NumberFormatException: ??.????????
at
java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1176)
at java.lang.Double.valueOf(Double.java:185)
at java.lang.Double.<init>(Double.java:260)
at testNumber.main(testNumber.java:39)
try this source code
------------------------------------------------
// testNumber
// test subclasses of Number, assigning value with Thai digits
// BigDecimal, BigInteger, Byte, Integer, Long, Short, Double, Float
//
// Jan 25, 2000 - Art!
import java.lang.Number;
import java.math.BigDecimal;
import java.math.BigInteger;
public class testNumber {
static public void main(String[] args) {
// BigDecimal
BigDecimal bd = new BigDecimal("\u0e51\u0e50.\u0e50\u0e51");
System.out.println(
"1) BigDecimal(\"\u0e51\u0e50.\u0e50\u0e51\") = "+bd.doubleValue());
// BigInteger
BigInteger bi = new BigInteger("\u0e52\u0e50\u0e50\u0e50");
System.out.println(
"2) BigDecimal(\"\u0e52\u0e50\u0e50\u0e50\") = "+bi.longValue());
// Byte
Byte b = new Byte("\u0e53\u0e50");
System.out.println("3) Byte(\"\u0e53\u0e50\") = "+b.byteValue());
// Integer
Integer i = new Integer("\u0e54\u0e50\u0e50");
System.out.println("4) Integer(\"\u0e54\u0e50\u0e50\") = "+i.intValue());
// Long
Long l = new Long("\u0e55\u0e55\u0e55\u0e55\u0e55\u0e55\u0e55");
System.out.println(
"5) Long(\"\u0e55\u0e55\u0e55\u0e55\u0e55\u0e55\u0e55\") = "+l.longValue());
// Short
Short s = new Short("\u0e56\u0e50");
System.out.println("6) Short(\"\u0e56\u0e50\") = "+s.shortValue());
// Double
Double d = new Double(
"\u0e57\u0e57.\u0e50\u0e50\u0e57\u0e57\u0e50\u0e50\u0e57\u0e57");
System.out.println(
"7) Double(\"\u0e57\u0e57.\u0e50\u0e50\u0e57\u0e57\u0e50\u0e50\u0e57\u0e57\") ="
+d.doubleValue());
// Float
Float f = new Float("\u0e58\u0e58.\u0e58\u0e58\u0e58");
System.out.println("8) Float(\"\u0e58\u0e58.\u0e58\u0e58\u0e58\") = "+f.floatValue());
System.out.println("\n.end test");
}
}
------------
as the result give the Thai characters,
please see the captured screeshot at
http://bacteria.thethai.net/bugs/j2se14b/thaidigits/ThaiDigitsValue.html
1st pic is Java 1.4 beta
2nd pic is Java 1.2.2 thai
-------------
this seems that Double and Float don't support Thai digits,
but it works for Byte, Integer, Long, BigDecimal, BigInteger.
Java 2 v.1.2.2 Thai Localization can handles all of number objects.
download j1.2.2_th
http://www.sun.co.th/developers/thailand
(Review ID: 126557)
======================================================================
- duplicates
-
JDK-4449157 Float.parseFloat() method is not Internationalized
-
- Closed
-