Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.Locale;

public class Main {
    private static String setNMEAformat(double latlong) {
        /*
          double latlongInt = Math.floor(latlong);
          double latLonDecimal = 60.0D * (latlong - latlongInt);
            
          String latLonDecimalStr = String.format(Locale.US, "%7.5f", latLonDecimal);
          if (latLonDecimalStr.indexOf(".") < 2)
          latLonDecimalStr = "0" + latLonDecimalStr;
            
          return String.format(Locale.US, "%1.0f", latlongInt) + latLonDecimalStr;
         */
        int latlongInt = (int) latlong;
        double latLonDecimal = 60.0D * (latlong % 1);

        String latLonDecimalStr = String.format(Locale.US, "%7.5f", latLonDecimal);
        if (latLonDecimalStr.indexOf(".") < 2)
            latLonDecimalStr = "0" + latLonDecimalStr;

        return String.format(Locale.US, "%d", latlongInt) + latLonDecimalStr;
    }
}