Here you can find the source of toDegrees(double degrees, int nDecimals, boolean longitude)
public final static String toDegrees(double degrees, int nDecimals, boolean longitude)
//package com.java2s; import java.text.NumberFormat; public class Main { public static final String degreeSign = "\u00b0"; public final static String toDegrees(double degrees, int nDecimals, boolean longitude) { NumberFormat degreesFormatter = NumberFormat.getInstance(); degreesFormatter.setMinimumFractionDigits(nDecimals); degreesFormatter.setMaximumFractionDigits(nDecimals); degreesFormatter.setMinimumIntegerDigits(longitude ? 3 : 2); String hemisphere = longitude ? (degrees >= 0.0 ? "E" : "W") : (degrees >= 0.0 ? "N" : "S"); String degString = Integer.toString((int) Math.abs(Math.floor(degrees))); String zeroes = "00".substring(0, (longitude ? 3 : 2) - degString.length()); degString = zeroes + degString;/*from ww w .j a v a 2 s . c o m*/ return degreesFormatter.format(degrees) + degreeSign + hemisphere; } }