ZipTz4J is a Java library for mapping US zip codes to timezones. It is a port of the infused/ziptz Ruby library.
Gradle (Kotlin)
dependencies {
implementation("dev.surratt:ziptz4j:0.1.1")
}
Gradle (Groovy)
dependencies {
compile 'dev.surratt:ziptz4j:0.1.1'
}
import dev.surratt.ziptz4j;
final ZipCode zipCode = ZipCode.getZipCode("97034-1234");
System.out.println("Zipcode 97034-1234 is in timezone " + zipCode.getTimeZone());
The code above produces the following output:
Zipcode 97034-1234 is in timezone America/Los_Angeles
The zip code must be in one of the following formats:
08402
174068026
98103-8634
A String of any other format will cause an IllegalArgumentException to be thrown.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.