• Post Reply Bookmark Topic Watch Topic
  • New Topic

Double parsing with ,  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Can someone help me with this simple question i have ?

I have a field with a decimal, and i want to parse it to a Double.

But because the delimiter is , and not . it fails.

This smal code represents what i want:



This will throw a NumberFormatException because of the ,

So how can i do this in i nice way, without it fails with.

And i don't want to use String replaceAll(arg0, arg1), if i can avoid it.

Best Regard
Cemil
[ February 13, 2007: Message edited by: Cemil Ozdemir ]
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at DecimalFormat and its parse method. This will give you more control than the basic Double methods.
 
Cemil Ozdemir
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Thanks for the quick reply.

I solved it by using the DecimalFormat as you mentioned.

Best Regards
Cemil
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!