1 package au.gov.amsa.geo.model; 2 3 import java.text.SimpleDateFormat; 4 5 import au.gov.amsa.risky.format.HasPosition; 6 import au.gov.amsa.util.navigation.Position; 7 8 import com.google.common.base.Optional; 9 10 public class Util { 11 public static Position toPos(HasPosition a) { 12 return new Position(a.lat(), a.lon()); 13 } 14 15 public static double greatCircleDistanceNm(HasPosition p1, HasPosition p2) { 16 return toPos(p1).getDistanceToKm(toPos(p2)) / 1.852; 17 } 18 19 public static String formatDate(Optional<Long> time) { 20 if (time.isPresent()) { 21 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 22 return sdf.format(time.get()); 23 } else 24 return ""; 25 } 26 }