Skip to content

Commit

Permalink
Use ZoneOffset to parse offset
Browse files Browse the repository at this point in the history
  • Loading branch information
naotoj committed Oct 16, 2023
1 parent d38c58a commit 3d22155
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.time.*;
import java.util.*;
import java.util.ResourceBundle.Control;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
Expand Down Expand Up @@ -97,7 +96,6 @@ public class CLDRConverter {
private static final String STD = "std";
private static final String DST = "dst";
private static final String NO_SUBST = "-";
private static final Pattern OFFSET_PATTERN = Pattern.compile(("([-+]\\d{2})(\\d{2})*"));

private static SupplementDataParseHandler handlerSuppl;
private static LikelySubtagsParseHandler handlerLikelySubtags;
Expand Down Expand Up @@ -1372,14 +1370,12 @@ private static void fillTZDBShortNames(String tzid, String[] names) {
* If it cannot recognize the pattern, return the argument as is.
*/
private static String convertGMTName(String f) {
var m = OFFSET_PATTERN.matcher(f);

if (m.matches()) {
var min = m.group(2);
return "GMT" + m.group(1) + (min != null ? ":" + min : ":00");
} else {
return f;
try {
return TimeZone.getTimeZone(ZoneOffset.of(f)).getDisplayName();
} catch (DateTimeException dte) {
// ignore
}
return f;
}

// for debug
Expand Down

0 comments on commit 3d22155

Please sign in to comment.