REGEXVAULTv2.0
Localization/Time Formats
Verified Safe

IANA Timezone Identifier Regex for Java

/^(?:Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific|Etc)/[A-Za-z0-9_+\-]+(?:/[A-Za-z0-9_+\-]+)?$/

What this pattern does

This page provides a comprehensive, battle-tested regular expression for matching iana timezone identifier, ported and verified for Java. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. The snippet below is ready to drop into your Java project — whether you're validating in a Spring Boot controller, a Jakarta EE service, or a standalone utility class.

Java Implementation

Java
// IANA Timezone Identifier
// ReDoS-safe | RegexVault — Localization > Time Formats

import java.util.regex.Pattern;

public class IanaTimezoneIdentifierValidator {
    private static final Pattern PATTERN =
        Pattern.compile("^(?:Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific|Etc)/[A-Za-z0-9_+\\-]+(?:/[A-Za-z0-9_+\\-]+)?$");

    public static boolean validate(String input) {
        return PATTERN.matcher(input).matches();
    }

    // Example
    public static void main(String[] args) {
        System.out.println(validate("America/New_York")); // true
    }
}

Test Cases

Matches (Valid)
Rejects (Invalid)
America/New_YorkEST
Europe/LondonUTC+8
Asia/SingaporeNew_York
Asia/KolkataAmerica/New York
Australia/SydneyAmerica/
Pacific/AucklandUS/Eastern
Etc/UTC

When to use this pattern

This pattern is drawn from the Localization > Time Formats category and carries a ReDoS-safe certification. That matters for Java developers because critical in Java applications since the JVM regex engine uses backtracking and is susceptible to ReDoS without careful pattern design. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

IANA zone names can change when countries change their timezone rules. The tzdb is updated multiple times per year. Always use the latest version in your runtime.

Technical Notes

IANA timezone database (TZDB/Olson database) is the global standard. Format: Area/Location or Area/Location/Subzone. Etc/* zones are for UTC offsets. US/*, Canada/*, US/Eastern are deprecated aliases.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern