Fix script selection in locales for TZ names.

Fix how we pass the locale ID to ICU4C. Previously we incorrectly passed
the result of Locale.toString() (which is a hybrid, legacy-based value)
instead of Locale.toLanguageTag() (which is well-specified by BCP 47 and
what ICU4C actually expects).

The only known case where this actually leads to an observable
difference is when the Locale includes an explicit script identifier.

For example the (BCP 47) locale id sr-Latn-RS would be represented by
Locale.toString as "sr_RS_#Latn". When parsing that string in ICU4C, the
last part will be ignored, as it's not well-formed.

Bug: 30527513
Tested: libcore.java.text.SimpleDateFormatTest
    libcore.java.util.TimeZoneTest libcore.icu.TimeZoneNamesTest

Change-Id: I9fbfdff8b896662d71576fe33f03eb660ecacaaf
2 files changed