Spring Data Reactive MongoDb :: Date Aggeration with Timezone

A short example on how to aggravate by date with a different timezone using Spring Data Reactive Mongodb. Code Snippet on github


    public Flux getHourlyReport() {
        DateOperators.Timezone timezone = DateOperators.Timezone.valueOf("America/New_York");
        Aggregation aggregation = Aggregation.newAggregation(Aggregation.project()
                        .and(DateOperators.Hour.hour("$tweet.createdAt")
                                .withTimezone(timezone))
                        .as("hour")
                , Aggregation.group("hour").count().as("sum"));
        Flux data = this.mongoTemplate.aggregate(aggregation, "realTweets", Map.class);
        return data;
    }


Comments

Popular posts from this blog

SSIS Package : Export Data from Database, Daily to New Excel Without Using Script Task

Getting Started With ForkJoinPool - Map & Reduce of Java