How to convert DMS (degrees, minutes, secondes) to DD (decimal degrees) Geographic Coordinates

DMS(degrees, minutes, secondes) -> DD(Latitude, Longitude)

public static Double[] dmsToLatLong(String emisferioLatitude, Double latitude_degres, Double  latitude_minutes, Double latitude_secondes, String emisferioLongitude, Double longitude_degres, Double longitude_minutes, Double longitude_secondes) throws Exception {

    int nordsud = 0;
    int estouest = 0;

    Double lat, lng;

    Double latitude, longitude;

    int S = -1;
    int N = 1;
    int W = -1;
    int E = 1;

    if (emisferioLatitude.equals("S")) {
      nordsud = S;
    } else if (emisferioLatitude.equals("N")) {
      nordsud = N;
    }

    if (emisferioLongitude.equals("W")) {
      estouest = W;
    } else if (emisferioLongitude.equals("E")) {
      estouest = E;
    }

    if (nordsud == 0) {
      throw new Exception("Error!");
    }

    if (estouest == 0) {
      throw new Exception("Error!");
    }

    lat = nordsud * (latitude_degres + latitude_minutes / 60 + latitude_secondes / 3600);
    lng = estouest * (longitude_degres + longitude_minutes / 60 + longitude_secondes / 3600);

    latitude = (double) (lat * 10000000) / 10000000;
    longitude = lng;

    return new Double[]{latitude, longitude};
  }

How to call the function

public static void main(String[] args) throws NumberFormatException, Exception {
  dmsToLatLong("S", Double.parseDouble("08"), Double.parseDouble("00"), Double.parseDouble("54.598"), "W", Double.parseDouble("35"), Double.parseDouble("07"), Double.parseDouble("58.853"));
}