Calculate periodic consumption of gas based on meter readings

Some quick comments:

  • Since you only ever use the milliseconds in your calculations anyway, don’t bother to create DateTimes for oldDate and newDate. Just keep the millis.

  • Since the calculations are pretty much all identical with the main difference being the time periods and Items you should use a lambda and avoid the duplicated code. Reusable Functions: A simple lambda example with copious notes

1 Like