Here is the Haversine Formula followed by the java code. I've added Miles, KM, Meters, CM, Feet and Yards methods as well.
|a = sin²(Δφ/2) + cos(φ1).cos(φ2).sin²(Δλ/2)|
c = 2.atan2(√ , √ )
d = R.c
|where||φ is latitude, λ is longitude, R is earth’s radius (mean radius = 6,371km)|
|note that angles need to be in radians to pass to trig functions!|