Here you can find the source of toDecimalFromSexagesimalDegrees( final double sexagesimal)
public static double toDecimalFromSexagesimalDegrees( final double sexagesimal)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; import java.text.NumberFormat; public class Main { public static double toDecimalFromSexagesimalDegrees( final double sexagesimal) { final String string = getFormat().format(sexagesimal); final int dotIndex = string.indexOf('.'); final int degrees = Integer.parseInt(string.substring(0, dotIndex)); final int minutes = Integer.parseInt(string.substring(dotIndex + 1, dotIndex + 3));//from ww w . j a v a 2 s . co m final double seconds = Double.parseDouble(string.substring( dotIndex + 3, dotIndex + 5) + "." + string.substring(dotIndex + 5)); double decimal; if (sexagesimal < 0) { decimal = degrees - minutes / 60.0 - seconds / 3600.0; } else { decimal = degrees + minutes / 60.0 + seconds / 3600.0; } return decimal; } private static NumberFormat getFormat() { return new DecimalFormat("#0.00000##########################"); } }