shadows/framework/src/main/java/org/robolectric/shadows/ShadowUsageStatsManager.java
public void simulateTimeChange(long offsetToAddInMillis) {
    ImmutableMap.Builder<Long, Event> eventMapBuilder = ImmutableMap.builder();
    for (Event event : eventsByTimeStamp.values()) {
      long newTimestamp = event.getTimeStamp() + offsetToAddInMillis;
      eventMapBuilder.put(
          newTimestamp, EventBuilder.fromEvent(event).setTimeStamp(newTimestamp).build());
    }
    eventsByTimeStamp.putAll(eventMapBuilder.build());
  }
public void simulateTimeChange(long offsetToAddInMillis) {
    ImmutableMap.Builder<Long, Event> eventMapBuilder = ImmutableMap.builder();
    for (Event event : eventsByTimeStamp.values()) {
      long newTimestamp = event.getTimeStamp() + offsetToAddInMillis;
      eventMapBuilder.put(
          newTimestamp, EventBuilder.fromEvent(event).setTimeStamp(newTimestamp).build());
    }
    eventsByTimeStamp.putAll(eventMapBuilder.build());
  }
public void simulateTimeChange ( long offsetToAddInMillis ) { ImmutableMap . Builder < Long , Event > eventMapBuilder = ImmutableMap . builder ( ) ; for ( Event event : eventsByTimeStamp . values ( ) ) { long newTimestamp = event . getTimeStamp ( ) + offsetToAddInMillis ; eventMapBuilder . put ( newTimestamp , EventBuilder . fromEvent ( event ) . setTimeStamp ( newTimestamp ) . build ( ) ) ; } eventsByTimeStamp . putAll ( eventMapBuilder . build ( ) ) ; }
Simulates the operations done by the framework when there is a time change. If the time is
changed, the timestamps of all existing usage events will be shifted by the same offset as the
time change, in order to make sure they remain stable relative to the new time.

<p>This method won't affect the results of {@link #queryUsageStats} method.

@param offsetToAddInMillis the offset to be applied to all events. For example, if {@code
offsetInMillis} is 60,000, then all {@link Event}s will be shifted forward by 1 minute
(into the future). Likewise, if {@code offsetInMillis} is -60,000, then all {@link Event}s
will be shifted backward by 1 minute (into the past).
Simulates the operations done by the framework when there is a time change . If the time is changed the timestamps of all existing usage events will be shifted by the same offset as the time change in order to make sure they remain stable relative to the new time .