How to get a custom type instead of Integer when using Collectors.summingInt?

Viewed 361

I am currently creating a Map<String, Map<LocalDate, Integer>> like this, where the Integer represents seconds:

Map<String, Map<LocalDate, Integer>> map = stream.collect(Collectors.groupingBy(
            x -> x.getProject(),
            Collectors.groupingBy(
                x -> x.getDate(),
                Collectors.summingInt(t -> t.getDuration().toSecondOfDay())
            )
        ));

How could I instead create a Map<String, Map<LocalDate, Duration>>?

2 Answers
Related