SunriseSunsetLib Java Library

repository·master·Indexed 43 days ago

https://github.com/mikereedell/sunrisesunsetlib-java

A Java library for computing local sunrise and sunset times based on latitude, longitude, and date using the Williams algorithm. Provides the SunriseSunsetCalculator class to retrieve times as formatted strings or Calendar objects.

Tokens
532
Snippets
4
Records
4
Agent score
5%

What's inside SunriseSunsetLib

  1. Calculate sunrise and sunset times

    master

    To use the library, first instantiate a Location object with latitude and longitude strings, then create a SunriseSunsetCalculator using that location and a valid time zone identifier (e.g., "America/New_York"). You can then retrieve sunrise/sunset times as either formatted Strings or Calendar objects for a specific date.

    Location location = new Location("39.9522222", "-75.1641667");
    SunriseSunsetCalculator calculator = new SunriseSunsetCalculator(location, "America/New_York");
    
    // Get sunrise as a String
    String officialSunrise = calculator.getOfficialSunriseForDate(Calendar.getInstance());
    
    // Get sunset as a Calendar object
    Calendar officialSunset = calculator.getOfficialSunsetCalendarForDate(Calendar.getInstance());