Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.MessageFormat;

public class Main {
    public static String transDistanceToStandardFormat(double distance) {
        if (distance < 1000) {
            return MessageFormat.format("{0} m", String.format("%.2f", distance));
        }
        return MessageFormat.format("{0} km", String.format("%.2f", distance / 1000));
    }
}