Java.util.Locale seems to exist in CodenameOne but is not found

44 views
Skip to first unread message

lana.si...@gmail.com

unread,
May 3, 2017, 1:28:11 AM5/3/17
to CodenameOne Discussions
Hi, 

I am having a bug when compiling my project on some platforms but not others.
I figured out that I need to use the java.util.Locale class to fix my issue. It seems to exist in codename one: 


But when I try to import and use it I get a not found error:

 error: cannot find symbol
import java.util.Locale;
  symbol:   class Locale
  location: package java.util

Any idea what is going on? Thanks for your help

If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans
Mac and windows
Simulator

lana.si...@gmail.com

unread,
May 3, 2017, 10:32:02 PM5/3/17
to CodenameOne Discussions, lana.si...@gmail.com
If the package does not actually exist, what is the replacement? Can someone point me towards a workaround?
Here is the bug at the root of my question:

        String date_s = "Fri Mar 31 10:02:51 +0000 2017"
        SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd hh:mm:ss zzzzz yyyy");
        Date date = null;
        try {
             date = formatter.parse(date_s);
                  } catch (ParseException ex) {
             Log.p(ex.toString());
        }

This code compiles and run on some machines but not on others: it gives a "date cannot be parsed" error, and it seems that using

SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd hh:mm:ss zzzzz yyyy", Locale.ENGLISH)

Would solve this issue.

Shai Almog

unread,
May 4, 2017, 1:09:17 AM5/4/17
to CodenameOne Discussions, lana.si...@gmail.com
We don't support the Locale class. You need to use the version of that method that doesn't take a Locale. We also provide L10NManager for various localization API's.

Notice there is a SimpleDateFormat under com.codename1.l10n which is more portable and should be used instead of the one from the java standard packages.

lana.si...@gmail.com

unread,
May 4, 2017, 5:02:18 AM5/4/17
to CodenameOne Discussions, lana.si...@gmail.com
Hi Shai, thank you for the answer.

>> com.codename1.l10n

I know it's not easy to be responsive and all, but you solved my issue.
Fast and accurate! Thanks again. 
Reply all
Reply to author
Forward
0 new messages