A Java library for calculation of sun and moon positions and phases.
It is a Java port of the great SunCalc JavaScript library by Vladimir Agafonkin, with some modifications and Java-nizations to the API.
- Lightweight, only requires Java 1.7 or higher
- Android support
- Available at Maven Central
This library consists of a few models, all of them are invoked the same way:
Date date = // date of calculation
double lat, lng = // geolocation
SunPosition position = SunPosition.of(date, lat, lng);
System.out.println("Altitude: " + position.getAltitude());
System.out.println("Azimuth: " + position.getAzimuth());
See the online documentation for API.
- Fork the Source code at GitHub. Feel free to send pull requests.
- Found a bug? File a bug report if you think it is a bug in the Java port.
- For bugs in the calculation, and feature requests that are not related to the Java port, please file a bug report at SunCalc.
commons-suncalc is open source software. The source code is distributed under the terms of Apache License 2.0.