View Full Version : Locale and Number Formatting

03-04-2010, 05:14 PM
On german servers you will experience that
$sql = 'SELECT * FROM employee WHERE salary < ' . 707.11;
leads to a SQL syntax error because 707.11 is translated to '707,11000000000' thus the statement reads
SELECT * FROM employee WHERE salary < 707,11000000000

One of the possible workarounds will be to set the default locale from PHP. This affects the whole virtual machine. Use this PHP code:
$locale = java_class('java.util.Locale');
$english = new Java('java.util.Locale', 'en'); // $locale->ENGLISH does not work.

Another, more elegant way would be to write a context listener in Java having the default locale set only once when the context is starting up.