Here you can find the source of lonLatToString(Point2D.Double pt)
public static String lonLatToString(Point2D.Double pt)
//package com.java2s; //License from project: Creative Commons License import java.awt.geom.Point2D; public class Main { public static final char DEGREE_SYMBOL = (char) 0xb0; /**//from w w w . j a va 2 s . c om * Converts signed double longitude and latitude to string. * @see Util#longitudeToString(double) * @see Util#latitudeToString(double) */ public static String lonLatToString(Point2D.Double pt) { return String.format("%s, %s", longitudeToString(pt.x), latitudeToString(pt.y)); } /** * Converts signed double longitude to string east or west value. * @param lon longitude * @return string rep of longitude */ public static String longitudeToString(double lon) { while (lon < -180) { lon += 360; } while (lon > 180) { lon -= 360; } char ew = 'E'; if (lon < 0) { ew = 'W'; } lon = Math.abs(lon); return String.format("%.4f", lon) + DEGREE_SYMBOL + ew; } /** * Converts signed double latitude to string north or south value. * @param lat latitude * @return string rep of latitude */ public static String latitudeToString(double lat) { char ns = 'N'; if (lat < 0) { ns = 'S'; } lat = Math.abs(lat); return String.format("%.4f", lat) + DEGREE_SYMBOL + ns; } }