• Stars
    star
    107
  • Rank 323,587 (Top 7 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Calculate sun and moon times in Java

commons-suncalc build status maven central

A Java library for calculation of sun and moon positions and phases.

Features

  • Lightweight, only requires Java 8 or higher, no other dependencies
  • Android compatible, requires API level 26 (Android 8.0 "Oreo") or higher. For older Android versions, use commons-suncalc v2, which is similar to this version, but does not use the Java Date/Time API.
  • Available at Maven Central
  • Extensive unit tests

Accuracy

Astronomical calculations are far more complex than throwing a few numbers into an obscure formula and then getting a fully accurate result. There is always a tradeoff between accuracy and computing time.

This library has its focus on getting acceptable results at low cost, so it can also run on mobile devices, or devices with a low computing power. The results have an accuracy of about a minute, which should be good enough for common applications (like sunrise/sunset timers), but is probably not sufficient for astronomical purposes.

If you are looking for the highest possible accuracy, you are looking for a different library.

Quick Start

This library consists of a few models, all of them are invoked the same way:

ZonedDateTime dateTime = // date, time and timezone of calculation
double lat, lng = // geolocation
SunTimes times = SunTimes.compute()
        .on(dateTime)   // set a date
        .at(lat, lng)   // set a location
        .execute();     // get the results
System.out.println("Sunrise: " + times.getRise());
System.out.println("Sunset: " + times.getSet());

Read the online documentation for examples and API details.

See the migration guide for how to migrate from a previous version.

References

This library bases on:

  • "Astronomy on the Personal Computer", 4th edition, by Oliver Montenbruck and Thomas Pfleger
  • "Astronomical Algorithms" by Jean Meeus

Contribute

License

commons-suncalc is open source software. The source code is distributed under the terms of Apache License 2.0.

More Repositories

1

acme4j

Java client for ACME (Let's Encrypt)
Java
474
star
2

tzxtools

Tools for processing TZX files
Python
83
star
3

phpminigallery

A very simple PHP image gallery
PHP
50
star
4

kaminari

AS3935 and ESP8266 based Franklin Lightning Detector
C++
37
star
5

pyquaero

Aquaero library and server written in Python
Python
27
star
6

identify

Amiga library for hardware identification
Assembly
23
star
7

pynaroma

Convert Amiga ROM images to BIN dumps, or vice versa
Python
16
star
8

yami

Amiga and Atari ST serial mouse interface
Assembly
15
star
9

commons-captcha

Generator for simple captcha images
Java
10
star
10

flattr4j

Java and Android client for Flattr API
Java
10
star
11

dustycase

3D printed frame for a Particulates Sensor
OpenSCAD
10
star
12

patchwork

Amiga library call validator
Assembly
9
star
13

a4000-bom

Amiga 4000D Rev B Bill of Materials
Python
7
star
14

fritzswitch

Small python command line tool for controlling Fritz!Box home automation
Python
5
star
15

commons-pdb

Read PalmOS PDB files with Java
Java
4
star
16

maestix

Amiga driver for the MaestroPro sound card
Assembly
4
star
17

cilla

Weblog and gallery software written in Java
Java
3
star
18

acarsclient

A Java client for acarsd
Java
3
star
19

jinn

Java tool for translating properties files into other languages
Java
3
star
20

pdbconverter

Converter for PalmOS calendar, addressbook, memo, ...
Java
3
star
21

cracker

Text, graphics and font ripper for the ZX Spectrum
Assembly
2
star
22

shariff-backend-java

A Java servlet and backend for Shariff
Java
2
star
23

pdalink

Connect your Amiga to Palm PDAs
C
2
star
24

commons-taglib

Taglib support for Spring
Java
2
star
25

nextskeleton

A skeleton generator for ZX Spectrum Next projects
Python
2
star
26

zxspectrum-bom

ZX Spectrum 48K Issue 3B Bill of Materials
Python
2
star
27

lighting

DIY Wall Bias Lighting
C++
1
star
28

emtea

Exim mail server setup with PHP config
PHP
1
star
29

lora-connect

Connect a Home Connect enabled clothes washer to MQTT using LoRa
C++
1
star
30

flufftron

A fluff management system.
1
star
31

simtv

An Arduino TV Simulator
C
1
star
32

feinrip

GUI frontend for converting mpeg to mkv files
Java
1
star
33

bullshitcharts

Web tool for generating random fake charts
Java
1
star
34

ooperldoc

API documentation generator for Perl source codes
Perl
1
star
35

jshred

Collection of more or less useful Java and Swing classes
Java
1
star
36

commons-gravatar

Proxy for Gravatar avatar images
Java
1
star
37

mkdocs-maven-plugin

A maven plugin for mkdocs
Java
1
star