Answer the question
In order to leave comments, you need to log in
How to group times in Unix-time by day?
Hello.
There is a collection of entities (conditionally an event), which have a field
This field stores time in UnixTime format. I need to count the number of events that happened in days. That is, ideally, you want to get at the output , where the key is the day (just a day, without time), and the value is the number of events.
And something I have an algorithmic plug. I feel that I need to write a function for , which takes UnixTime as input, and gives a date without time as output. But at the same time, I also want it so that the comparison of the date is only year-month-day, so that you can then group the .Long time; // System.currentTimeInMillis()
Map<Date, Integer>
stream().map()
Collectors.groupBy()
Actually, the question is - is there a ready-made class that stores only the date (without time) and / or which implements equals taking into account the date without time. Or do you have to write your own wrapper?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question