Skip to content

Instantly share code, notes, and snippets.

@smallufo
Last active January 1, 2018 08:17
Show Gist options
  • Save smallufo/295c2e82fc1f09d7bede3acccad653e2 to your computer and use it in GitHub Desktop.
Save smallufo/295c2e82fc1f09d7bede3acccad653e2 to your computer and use it in GitHub Desktop.
LocalDateTime getNextFullMoon(LocalDateTime from);
default List<LocalDateTime> getYearlyFullMoons(int year) {
List<LocalDateTime> result = new ArrayList<>();
LocalDateTime from = LocalDateTime.of(year , 1 , 1 , 0 , 0);
while (from.getYear() < year+1) {
LocalDateTime fullMoon = getNextFullMoon(from);
if (fullMoon.getYear() == year)
result.add(fullMoon);
from = fullMoon.plusDays(1);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment