clojure.core/format localization problems

552 views
Skip to first unread message

dabd

unread,
Mar 9, 2013, 7:39:57 PM3/9/13
to clo...@googlegroups.com
On my system I have:

> *clojure-version*
{:major 1, :minor 4, :incremental 0, :qualifier nil}

> (java.util.Locale/getDefault)
#<Locale en_US>


> (format "%.1f" 0.5)
"0,5"

> (java.lang.String/format (java.util.Locale/getDefault) "%.1f" (to-array [0.5]))
"0.5"

but 

> (java.lang.String/format  "%.1f" (to-array [0.5]))
"0,5"

How can I set clojure.core/format to display numbers with a dot decimal separator?
Why calling java.lang.String/format with the default locale returns a different value than calling it without specifying the locale (javadoc says it uses the default locale so they should return the same value)?

Thanks.


Andy Fingerhut

unread,
Mar 9, 2013, 8:27:49 PM3/9/13
to clo...@googlegroups.com
What OS and version of Java are you using (output of "java -version", and if on Linux "lsb_release -a" and "uname -a").

Are you doing these commands one after another in a single REPL session?  If so, how did you start that REPL?

I've tried the commands you mention on these OS and JDK combos with Clojure 1.4.0, and always saw "0.5" as the result, never "0,5".  My default locale was also en_US on all of these systems.

Mac OS X 10.6.8 + java version 1.6.0_43 (Oracle/Apple)
Ubuntu 11.10 with Linux kernel 3.0.0-31-generic + java version 1.6.0_27 (OpenJDK)
Windows 7 + java version 1.7.0_07 (Oracle)

Andy

--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

dabd

unread,
Mar 9, 2013, 10:22:21 PM3/9/13
to clo...@googlegroups.com
I am trying to run clojure on windows 7 with this java version:
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)

The decimal separator used to be a dot but for some reason it changed to a comma recently.  I didn't change any OS locale settings.

dabd

unread,
Mar 9, 2013, 10:39:00 PM3/9/13
to clo...@googlegroups.com
I installed the latest 1.7.0_17 and apparently the issue is gone but I still don't know what caused it.
Thanks.

dabd

unread,
Mar 17, 2013, 6:40:19 PM3/17/13
to clo...@googlegroups.com
I'm having this problem again.
I start the repl with nrepl-jack-in.  Also starting it on the command line with 'lein repl' shows the same problem.

What is causing the JVM to lose the default locale settings (at least in regard to number formatting)?

Thanks.

dabd

unread,
Mar 17, 2013, 8:48:51 PM3/17/13
to clo...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages