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.Formatter;

public class Main {
    public static String transferTP(String oldValue) {
        String newValue = oldValue;
        float ov = Float.valueOf(oldValue) / 1000;
        Formatter fmt = new Formatter();

        if (ov >= 100) {
            newValue = String.valueOf(Math.floor(ov + 0.5));
        } else if (ov > 10) {
            newValue = fmt.format("%.1f", ov).toString();
        } else {
            newValue = fmt.format("%.2f", ov).toString();
        }

        return newValue;
    }
}