I'm trying to use a java locale in Scala. Using a constant like java.util.Locale.ENGLISH
works well; however, java.util.Locale("en")
complains:
error: object Locale is not a value
java.util.Locale("en")`
This seems related to this question, which suggests Locale doesn't have a companion object. I've been reading a bit about this, but I still can't figure out how one is to access the Locale class?
Do not forget to instantiate locale with new keyword, since it's class:
scala> new java.util.Locale("en")
res0: java.util.Locale = en
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With