com.codename1.l10n.ParseException: Invalid timezone value

27 views
Skip to first unread message

kantha...@gmail.com

unread,
Oct 14, 2017, 11:23:20 AM10/14/17
to CodenameOne Discussions
Hi,

I'm doing a sample in CN1 and in this sample i tried to convert the date from one pattern to another.


here is method what i'm using to convert date:

 private String convertDateFormat(String fromDate) {

    DateFormat df=new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");

    Date d= null;
    try {
        d = df.parse(fromDate);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    df=new SimpleDateFormat("yyyyMMdd");
    System.out.println(df.format(d));

    return df.format(d);
}

calling the method

String convertedDate = convertDateFormat("Sun Aug 14 16:13:39 GMT+05:30 2016");

above code is working in simulator but when i runs in the device i'm getting "com.codename1.l10n.ParseException: Invalid timezone value" Exception..

How can i fix this?

Thanks


Shai Almog

unread,
Oct 15, 2017, 2:12:28 AM10/15/17
to CodenameOne Discussions

Dave Dyer

unread,
Oct 15, 2017, 3:19:51 PM10/15/17
to CodenameOne Discussions

The whole time parsing process is pretty awful (not codename1's fault).  Throwing an exception without useful information
about what caused it isn't very satisfactory, and if you're dealing with dates printed by random other programs there will never be an end to
creative "unacceptable" representations.

I ended up making my own time/date parser so I could deal with parse failures in a way that was satisfactory to my application.

Reply all
Reply to author
Forward
0 new messages