@@ -154,19 +154,13 @@ public Maybe<Session> getSession(
154154 if (config .numRecentEvents ().isEmpty () && config .afterTimestamp ().isPresent ()) {
155155 Instant threshold = config .afterTimestamp ().get ();
156156
157- eventsInCopy .removeIf (
158- event -> getEventTimestampEpochSeconds (event ) < threshold .getEpochSecond ());
157+ eventsInCopy .removeIf (event -> getInstantFromEvent (event ).isBefore (threshold ));
159158 }
160159
161160 // Merge state into the potentially filtered copy and return
162161 return Maybe .just (mergeWithGlobalState (appName , userId , sessionCopy ));
163162 }
164163
165- // Helper to get event timestamp as epoch seconds
166- private long getEventTimestampEpochSeconds (Event event ) {
167- return event .timestamp () / 1000L ;
168- }
169-
170164 @ Override
171165 public Single <ListSessionsResponse > listSessions (String appName , String userId ) {
172166 Objects .requireNonNull (appName , "appName cannot be null" );
@@ -294,10 +288,7 @@ public Single<Event> appendEvent(Session session, Event event) {
294288 /** Converts an event's timestamp to an Instant. Adapt based on actual Event structure. */
295289 // TODO: have Event.timestamp() return Instant directly
296290 private Instant getInstantFromEvent (Event event ) {
297- double epochSeconds = getEventTimestampEpochSeconds (event );
298- long seconds = (long ) epochSeconds ;
299- long nanos = (long ) ((epochSeconds % 1.0 ) * 1_000_000_000L );
300- return Instant .ofEpochSecond (seconds , nanos );
291+ return Instant .ofEpochMilli (event .timestamp ());
301292 }
302293
303294 /**
0 commit comments