Skip to content
Library for computing the sunrise/sunset from GPS coordinates and a date, in Java.
Java Ruby
Latest commit c0bfdeb Jan 20, 2015 @mikereedell Update README.markdown
Failed to load latest commit information.
src Fix for issue #9. Now accounting for non-integer timezone offsets. Dec 15, 2014
testdata Fix for issue #2: Error computing sunrise for a different timezone wh… May 8, 2012
.classpath Maven-izing the project. Only code change was the addition of a dummy… Oct 22, 2009
AllJUnitTests.launch Changes from user feedback (patch from Bengt Martensson). Jun 13, 2011
LICENSE Addiing LICENSE file for Apache 2.0 License. Changed build file to in… Jan 22, 2009
README.markdown Update README.markdown Jan 20, 2015
pom.xml [maven-release-plugin] prepare for next development iteration Dec 16, 2014


Sunrise/SunsetLib - Java


Java library to compute the local sunrise and sunset at a given latitude/longitue and date combination. Uses the algorithm found at




Download the jar or clone the repo and run $ mvn clean install to build from source.


You can now use Maven to pull in SunriseSunsetLib into your project, just add:


to your pom.xml.

If you use gradle, add the following to your build.gradle file:

repositories {

dependencies {
    compile 'com.luckycatlabs:SunriseSunsetCalculator:1.2'


Create a SunriseSunsetCalculator with a location and time zone identifier:

Location location = new Location("39.9522222", "-75.1641667");
SunriseSunsetCalculator calculator = new SunriseSunsetCalculator(location, "America/New_York");

Then call the method for the type of sunrise/sunset you want to calculate:

String officialSunrise = calculator.getOfficialSunriseForDate(Calendar.getInstance());
Calendar officialSunset = calculator.getOfficialSunsetCalendarForDate(Calendar.getInstance());

Bug Reports

When filing a bug report, please include the following information:

  • Date sunrise/set calculation was being run for.
  • Latitude/longitute sunrise/set calculation was being run for.
  • Timezone (either "America/New_York" or GMT-0500)


Mike Reedell

Donate with Pledgie


Apache License, Version 2.0

Something went wrong with that request. Please try again.