I extracted the lunar calculations from my Android app Lunar Locator into a standalone Java library.
The equations are from Jean Meeus' "Astronomical Algorithms." Given a time and location, it calculates relative lunar positions, rise/set times, distance, illumination, and more.