Formats a coordinate for pretty output. - Java java.lang

Java examples for java.lang:String Format

Description

Formats a coordinate for pretty output.

Demo Code


//package com.java2s;
import java.util.Locale;

public class Main {
    public static void main(String[] argv) {
        double coord = 42.45678;
        System.out.println(formatCoordinate(coord));
    }/* ww  w.  ja  v  a  2s  .co m*/

    /**
     * Formats a coordinate for pretty output.
     * 
     * @param coord
     *            The coordinate to format
     * @return The formatted coordinate
     */
    public static String formatCoordinate(double coord) {
        // 7 decimals is the OSM default
        return String.format(Locale.ENGLISH, "%.7f", coord);
    }
}

Related Tutorials