Here you can find the source of format(double degrees)
Parameter | Description |
---|---|
degrees | a parameter |
static protected String format(double degrees)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w.j a v a2 s .c o m * IBM Corporation - initial API and implementation *******************************************************************************/ import java.text.DecimalFormat; public class Main { /** * Remove decimal point from value and return its string representation * * @param degrees * * @return formatted string */ static protected String format(double degrees) { // String str = null; // String subStr = null; double dVal = degrees; // boolean negative = false; // Decimal format does the rounding for us. // if (dVal < -0.0000005) { // dVal -= 0.0000005; // } else if (dVal > 0.0000005) { // dVal += 0.0000005; // } // dVal *= 1000000.0; // int iVal = (int) dVal; // return ""+iVal; // str = Double.toString(dVal); // int dot = str.indexOf("."); //$NON-NLS-1$ // subStr = str.substring(0, str.length() < dot + 7 ? str.length() // : dot + 7); // return subStr; DecimalFormat form = new DecimalFormat("###0.000000"); //$NON-NLS-1$ return form.format(dVal); } /** * Format only six decimal digits after decimal point. * * @param value * unformatted value * * @return formatted string */ static protected String format(String value) { String subStr = null; int dot = value.indexOf("."); //$NON-NLS-1$ subStr = value.substring(0, value.length() < dot + 7 ? value.length() : dot + 7); return subStr; } }