Sergei Kozelko
11/06/2024, 3:46 AMLocale.setDefault
fails in playground with java.security.AccessControlException: Access control exception due to security reasons in web playground
. Is this on purpose?Olaf Gottschalk
11/06/2024, 8:04 AMNikolay Pachkov
11/06/2024, 2:16 PMjava.security.AccessControlException
you're encountering when calling Locale.setDefault
is intentional. Changing the default locale is a privileged operation, so it's restricted in the Playground for security reasons.
If you need to work with a specific locale, you can specify it explicitly in your code without changing the default. For example:
https://pl.kotl.in/bN4Yv863L
import java.text.NumberFormat
import java.util.Locale
fun main() {
val locale = Locale("fr", "FR")
val numberFormat = NumberFormat.getInstance(locale)
println(numberFormat.format(123456.789))
}