List of usage examples for android.location Location FORMAT_MINUTES
int FORMAT_MINUTES
To view the source code for android.location Location FORMAT_MINUTES.
Click Source Link
From source file:Main.java
public static String formatCoordinate(double coordinate, int outputType) { StringBuilder sb = new StringBuilder(); char endChar = DEGREE_CHAR; DecimalFormat df = new DecimalFormat("###.####"); if (outputType == Location.FORMAT_MINUTES || outputType == Location.FORMAT_SECONDS) { df = new DecimalFormat("##.###"); int degrees = (int) Math.floor(coordinate); sb.append(degrees);//from w ww . j a va 2 s . c o m sb.append(DEGREE_CHAR); // degrees sign endChar = '\''; // minutes sign coordinate -= degrees; coordinate *= 60.0; if (outputType == Location.FORMAT_SECONDS) { df = new DecimalFormat("##.##"); int minutes = (int) Math.floor(coordinate); sb.append(minutes); sb.append('\''); // minutes sign endChar = '\"'; // seconds sign coordinate -= minutes; coordinate *= 60.0; } } sb.append(df.format(coordinate)); sb.append(endChar); return sb.toString(); }
From source file:com.nextgis.firereporter.ScanexNotificationItem.java
/** * Formats coordinate value to string based on output type (modified version * from Android API)/*from w ww . ja va 2s. com*/ */ public static String formatCoord(double coordinate, int outputType) { StringBuilder sb = new StringBuilder(); char endChar = DEGREE_CHAR; DecimalFormat df = new DecimalFormat("###.######"); if (outputType == Location.FORMAT_MINUTES || outputType == Location.FORMAT_SECONDS) { df = new DecimalFormat("##.###"); int degrees = (int) Math.floor(coordinate); sb.append(degrees); sb.append(DEGREE_CHAR); // degrees sign endChar = '\''; // minutes sign coordinate -= degrees; coordinate *= 60.0; if (outputType == Location.FORMAT_SECONDS) { df = new DecimalFormat("##.##"); int minutes = (int) Math.floor(coordinate); sb.append(minutes); sb.append('\''); // minutes sign endChar = '\"'; // seconds sign coordinate -= minutes; coordinate *= 60.0; } } sb.append(df.format(coordinate)); sb.append(endChar); return sb.toString(); }