Problem situation: I have an incredibly high number of records all marked with a timestamp. I'm looping through all of them to do this and that but I need to detect when the day has changed.
Right now for each loop I'm doing:
cal.setTimeInMillis(record.time); int currentDay = cal.get(Calendar.DAY_OF_WEEK); Is this as slow as I imagine it is when it's running hundreds of thousands of times? I imagine I'm missing a really simple modulo answer or something.
Edit: Time zone does not matter, the information I'm collecting more resolves around a consumable report for someone. 24 hours per report is more accurate, so realistically I don't have to worry about whether or not that's 5am - 5am or 3pm - 3pm, just that I was able to gather 24H worth of info.
Thanks all
https://stackoverflow.com/questions/65905856/java-most-efficient-way-using-a-long-epoch-timestamp-to-detect-a-change-in-day January 27, 2021 at 01:06AM
没有评论:
发表评论