The net.iakovlev.timeshape.TimeZoneEngine class is the primary entry point. Initialization builds an index and reads data from resources, which takes approximately 1 second. It is recommended to perform initialization only once during the program's lifetime.
There are several ways to initialize the engine:
- Full World Data: Loads all available time zone data.
- Bounding Box: Reduces memory usage by loading only data within a specific geographic area. Note: The time zone must be completely covered by the bounding box, not just intersected by it.
- Specific ZoneIds: Loads only the requested
ZoneIds. - External File: Uses a
TarArchiveInputStream to load data from an external file (format must match the builder sbt project output). The caller is responsible for closing the input stream.
// Initialize with the whole world
TimeZoneEngine engine = TimeZoneEngine.initialize();
// Initialize with a bounding box (minLat, minLon, maxLat, maxLon)
TimeZoneEngine engine = TimeZoneEngine.initialize(47.0599, 4.8237, 55.3300, 15.2486);
// Initialize with specific ZoneIds
Set<ZoneId> timeZones = new HashSet<>();
timeZones.add(ZoneId.of("Europe/Berlin"));
timeZones.add(ZoneId.of("America/Detroit"));
TimeZoneEngine engine = TimeZoneEngine.initialize(timeZones, true);