Hai Zhang created LANG-1730:
-------------------------------

             Summary: DateUtils.parseDateWithLeniency() doesn't accept "GMT" as 
"zzz" timezone on Android
                 Key: LANG-1730
                 URL: https://issues.apache.org/jira/browse/LANG-1730
             Project: Commons Lang
          Issue Type: Bug
          Components: lang.time.*
    Affects Versions: 3.14.0
         Environment: Not working: Android 14 (API 34) phone and emulator, 
Android 12 (API 31) emulator

Working: Arch Linux OpenJDK 11
            Reporter: Hai Zhang


Commons Lang3 3.14.0 DateUtils, i.e. FastDateParser under the hood, doesn't 
accept "GMT" as a valid timezone for "zzz" on Android 14, but does accept it on 
desktop OpenJDK 11.

The same issue was reported at https://github.com/bitfireAT/dav4jvm/issues/22 , 
but I found that it's also not working on Android 12 emulator, so I believe the 
actual cause is Commons Lang3 using FastDateParser v.s. previously using 
SimpleDateFormat, instead of upgraded Android platform version.

I debugged this a little bit and found that the generated regex in 
FastDateParser.TimeZoneStrategy doesn't contain "|gmt|" on Android 14, but does 
contain "|gmt|" on desktop. I suspect maybe Android has some different timezone 
info. I also saw the intentional skip for `TimeZones.GMT_ID` in FastDateParser 
code, which makes me wonder how it got the "|gmt|" on desktop.

Here are the different generated regexes I saw, with unrelated timezones 
replaced with "...":

```
((?iu)[+-]\d{4}|GMT[+-]\d{1,2}:\d{2}|yukon time|...|gulf standard 
time|greenwich mean 
time|gmt-12:00|gmt-11:00|gmt-10:00|gmt-09:30|gmt-09:00|gmt-08:00|gmt-07:00|gmt-06:00|gmt-05:00|gmt-04:00|gmt-03:30|gmt-03:00|gmt-02:30|gmt-02:00|gmt-01:00|gmt\+14:00|gmt\+13:45|gmt\+13:00|gmt\+12:45|gmt\+12:00|gmt\+11:00|gmt\+10:30|gmt\+10:00|gmt\+09:30|gmt\+09:00|gmt\+08:45|gmt\+08:00|gmt\+07:00|gmt\+06:30|gmt\+06:00|gmt\+05:45|gmt\+05:30|gmt\+05:00|gmt\+04:30|gmt\+04:00|gmt\+03:30|gmt\+03:00|gmt\+02:00|gmt\+01:00|gmt\+00:00|gilbert
 islands time|...|acre standard time)
```

```
((?iu)[+-]\d{4}|GMT[+-]\d{1,2}:\d{2}|yekt|...|gulf daylight 
time|gt|gst|greenwich mean 
time|gmt-12:00|gmt-11:00|gmt-10:00|gmt-09:00|gmt-08:00|gmt-07:00|gmt-06:00|gmt-05:00|gmt-04:00|gmt-03:00|gmt-02:00|gmt-01:00|gmt\+14:00|gmt\+13:00|gmt\+12:00|gmt\+11:00|gmt\+10:00|gmt\+09:00|gmt\+08:00|gmt\+07:00|gmt\+06:00|gmt\+05:00|gmt\+04:00|gmt\+03:00|gmt\+02:00|gmt\+01:00|gmt|gilt|....|acre
 standard time|acdt)
```



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to