File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parse method discrepancy of NumberFormat(CurrencyFormatter)

 
Rahul Saple
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is the problematic code

The parse method of the NumberFormat(currency formatter) takes a string and returns a Number object.
However according to the book(Khalid Mughal), the space character which is used as a grouping character in formatting numbers in the norwegian locale, acts as a delimiter in a string and thereby results in the termination of any parsing.
If so, why does the second parse call return the original Number object while the first fails, when both accept the same string value as an argument.
Does it have to do anything with how the String is represented internally by the JVM?
 
Simone Aiello
Greenhorn
Posts: 22
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Effectively the input string "kr 1 233 232,00" and the one printed by the console, originated by the parsing, are different...
The space used as separator is a non-breaking space (ASCII code 160), while the other is breaking ( ASCII code 32)

you can perform a test by yourself, applying this on the two strings

 
Rahul Saple
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a bunch Simone. Even I was thinking somewhat on the same lines, but nowhere close. Thanks again.
 
Simone Aiello
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic