@Test
  public void do_test()
      throws InterruptedException,
          TException,
          IoTDBConnectionException,
          IOException,
          StatementExecutionException {
    final AtomicInteger rowCount = new AtomicInteger(0);
    final AtomicInteger onReceive = new AtomicInteger(0);
    // Write data before subscribing
    insert_data(1704038396000L); // 2023-12-31 23:59:56+08:00
    consumer =
        new SubscriptionTreePushConsumer.Builder()
            .host(SRC_HOST)
            .port(SRC_PORT)
            .consumerId("db_time_range_accurate_tsfile")
            .consumerGroupId("push_time")
            .ackStrategy(AckStrategy.AFTER_CONSUME)
            .fileSaveDir("target/push-subscription")
            .consumeListener(
                message -> {
                  try {
                    onReceive.addAndGet(1);
                    TsFileReader reader = message.getTsFileHandler().openReader();
                    List<Path> paths = new ArrayList<>(2);
                    for (int i = 0; i < 2; i++) {
                      paths.add(new Path(device, "s_" + i, true));
                    }
                    QueryDataSet dataset = reader.query(QueryExpression.create(paths, null));
                    while (dataset.hasNext()) {
                      rowCount.addAndGet(1);
                      RowRecord next = dataset.next();
                      System.out.println(next.getTimestamp() + "," + next.getFields());
                    }
                  } catch (IOException e) {
                    throw new RuntimeException(e);
                  }
                  return ConsumeResult.SUCCESS;
                })
            .buildPushConsumer();
    consumer.open();
    // Subscribe
    consumer.subscribe(topicName);
    subs.getSubscriptions().forEach(System.out::println);
    assertEquals(subs.getSubscriptions().size(), 1, "show subscriptions after subscription");

    AWAIT.untilAsserted(
        () -> {
          assertGte(onReceive.get(), 1);
          assertGte(rowCount.get(), 2);
        });

    insert_data(System.currentTimeMillis()); // now, not in range
    AWAIT.untilAsserted(
        () -> {
          assertGte(onReceive.get(), 1);
          assertGte(rowCount.get(), 2);
        });

    insert_data(1707782400000L); // 2024-02-13 08:00:00+08:00
    AWAIT.untilAsserted(
        () -> {
          assertGte(onReceive.get(), 2);
          assertGte(rowCount.get(), 6);
        });

    insert_data(1711814398000L); // 2024-03-30 23:59:58+08:00
    AWAIT.untilAsserted(
        () -> {
          assertGte(onReceive.get(), 3);
          assertGte(rowCount.get(), 8);
        });

    insert_data(1711900798000L); // 2024-03-31 23:59:58+08:00
    AWAIT.untilAsserted(
        () -> {
          assertGte(onReceive.get(), 3);
          assertGte(rowCount.get(), 8);
        });
  }
Start time, end time are both closed intervals. If not specified, the time will be 00:00:00.
integration-test/src/test/java/org/apache/iotdb/subscription/it/triple/treemodel/regression/pushconsumer/time/IoTDBTimeRangeDBTsfilePushConsumerIT.java