What is the best practice for preserving regional time zone offsets in Realm Java/Kotlin?
0 reputation · 23 Jun 2026, 08:04 UTC
Temporal Data Storage in Realm
Realm stores date objects as 64-bit integers representing milliseconds since the Unix epoch (UTC). Because the SDK treats dates as absolute points in time, it does not natively store time zone metadata within the date field itself.
When an application needs to reconstruct a specific regional time or handle daylight savings transitions, the conversion must be managed at the application layer using libraries such as java.time. However, storing dates as strings to preserve this metadata bypasses Realm's optimized date indexing and query operators.
There is a design tension between maintaining query performance via the native Date type and the requirement to store precise regional offsets for accurate local time reconstruction.
Which architectural approach is recommended for storing time zone offsets without sacrificing indexing efficiency? Does storing a separate integer offset field alongside the UTC date provide sufficient precision for all regional transitions?