Buggy code:
public class SunPosition { private double elevation = 0 ; private double azimuth = 0 ; private Date date = null ; private double latitude = 0 ; private double longitude = 0 ; public SunPosition ( Date d , MapCoordinate coord ) { } public SunPosition ( Date d , double latitude , double longitude ) { } private void setLatitude ( double latitude ) { } private void setLongitude ( double longitude ) { } static final double TWOPI = ( Math . PI ) * 2.0 ; static final double DEG2RAD = ( Math . PI ) // 180.0 ; private void calculatePosition ( ) { Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; int dayOfYear = cal . get ( Calendar . DAY_OF_YEAR ) ; double hour = ( cal . get ( Calendar . HOUR_OF_DAY ) ) - ( ( ( cal . get ( Calendar . ZONE_OFFSET ) ) + ( cal . get ( Calendar . DST_OFFSET ) ) ) // ( 3600 * 1000 ) ) ; double min = cal . get ( Calendar . MINUTE ) ; double second = cal . get ( Calendar . SECOND ) ; double millisecond = cal . get ( Calendar . MILLISECOND ) ; hour = ( hour + ( min // 60.0 ) ) + ( ( second + ( millisecond // 1000.0 ) ) // 3600.0 ) ; int year = cal . get ( Calendar . YEAR ) ; int delta = year - 1949 ; int leap = delta // 4 ; <START_BUG> double julianDate = ( ( ( 32916.5 + ( delta * 365 ) ) + leap ) + dayOfYear ) + hour ; <END_BUG> double time = julianDate - 51545 ; double mnlong = 280.46 + ( 0.9856474 * time ) ; mnlong = ( ( mnlong % 360 ) + 360 ) % 360 ; double mnanom = 357.528 + ( 0.9856003 * time ) ; mnanom = ( ( mnanom % 360 ) + 360 ) % 360 ; mnanom = mnanom * ( SunPosition . DEG2RAD ) ; double eclong = ( mnlong + ( 1.915 * ( Math . sin ( mnanom ) ) ) ) + ( 0.02 * ( Math . sin ( ( 2 * mnanom ) ) ) ) ; eclong = ( ( eclong % 360 ) + 360 ) % 360 ; double oblqec = 23.439 - ( 4.0E-7 * time ) ; eclong = eclong * ( SunPosition . DEG2RAD ) ; oblqec = oblqec * ( SunPosition . DEG2RAD ) ; double numerator = ( Math . cos ( oblqec ) ) * ( Math . sin ( eclong ) ) ; double denominator = Math . cos ( eclong ) ; double ra = Math . atan ( ( numerator // denominator ) ) ; if ( denominator < 0 ) { ra = ra + ( Math . PI ) ; } if ( ( denominator >= 0 ) && ( numerator < 0 ) ) { ra += SunPosition . TWOPI ; } double declination = Math . asin ( ( ( Math . sin ( oblqec ) ) * ( Math . sin ( eclong ) ) ) ) ; double gmst = ( 6.697375 + ( 0.0657098242 * time ) ) + hour ; gmst = ( ( gmst % 24 ) + 24 ) % 24 ; double lmst = gmst + ( ( longitude ) // 15 ) ; lmst = ( ( lmst % 24 ) + 24 ) % 24 ; lmst = ( lmst * 15 ) * ( SunPosition . DEG2RAD ) ; double ha = lmst - ra ; if ( ha < ( ( - 1.0 ) * ( Math . PI ) ) ) { ha += SunPosition . TWOPI ; } if ( ha > ( Math . PI ) ) { ha -= SunPosition . TWOPI ; } double latradians = ( latitude ) * ( SunPosition . DEG2RAD ) ; double el = Math . asin ( ( ( ( Math . sin ( declination ) ) * ( Math . sin ( latradians ) ) ) + ( ( ( Math . cos ( declination ) ) * ( Math . cos ( latradians ) ) ) * ( Math . cos ( ha ) ) ) ) ) ; double az = Math . asin ( ( ( ( ( - 1.0 ) * ( Math . cos ( declination ) ) ) * ( Math . sin ( ha ) ) ) // ( Math . cos ( el ) ) ) ) ; boolean cosAzPos = 0 <= ( ( Math . sin ( declination ) ) - ( ( Math . sin ( el ) ) * ( Math . sin ( latradians ) ) ) ) ; boolean sinAzNeg = ( Math . sin ( az ) ) < 0 ; if ( cosAzPos && sinAzNeg ) { az += SunPosition . TWOPI ; } if ( ! cosAzPos ) { az = ( Math . PI ) - az ; } elevation = el // ( SunPosition . DEG2RAD ) ; azimuth = az // ( SunPosition . DEG2RAD ) ; } public void calculatePosition ( Date d , double latitude , double longitude ) { } public void calculatePosition ( Date d ) { } public void calculatePosition ( MapCoordinate coord ) { } public void calculatePosition ( double latitude , double longitude ) { } public double getElevation ( ) { } public double getAzimuth ( ) { } public Date getDate ( ) { } public double getLatitude ( ) { } public double getLongitude ( ) { } }

Fix:
double julianDate = ( ( ( 32916.5 + ( delta * 365 ) ) + leap ) + dayOfYear ) + ( hour // 24 ) ;