Results 1 to 2 of 2
Thread: Scanner/Locale Trouble
- 10-15-2010, 04:03 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 17
- Rep Power
- 0
Scanner/Locale Trouble
(The title is misleading, this post has nothing to do with the Scanner class. Before I edited my post it had to do with the Scanner class, but not anymore).
Hey, I've made a simple GUI which contains some JTextFields (Swing) where the user gets to input a double (but since it's JTextFields the input gets stored in a String). In order to process inputed string and to extract the double I use Double.parseDouble(inputedString).
But it says it's an invalid input if I enter for example "3,14". Observe, ',' decimal point instead of a '.' (because it's swedish standards). So in order to get around this I tried adding this in the beginning of my code:
This kind of works since my program now outputs doubles with a ',' as decimal point. But I still can't input using a ','. Help? Let me know if you need the rest of my code.Java Code:Locale.setDefault(new Locale("sv","SE")); //according to this book I got, this should set it to swedish standards
Thanks.Last edited by plm-pusik; 10-15-2010 at 05:45 PM.
- 10-15-2010, 07:07 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
trouble with Scanner(new File("input"));
By ronyosi in forum New To JavaReplies: 9Last Post: 10-27-2010, 11:34 PM -
Scanner Trouble
By Snoman in forum New To JavaReplies: 3Last Post: 09-28-2010, 05:29 AM -
[SOLVED] Trouble with Scanner FileInputStream not finding the file
By miss.meli in forum New To JavaReplies: 0Last Post: 12-01-2008, 09:50 PM -
Locale example
By Java Tip in forum Java TipReplies: 0Last Post: 01-29-2008, 09:04 AM -
Locale
By Java Tip in forum Java TipReplies: 0Last Post: 11-16-2007, 02:16 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks