Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /** 
     * convert a string with a decimal and a unit such as "5.5 knots"
     * to -> " . 5 knots 5 . " 
     * **/
    public static String decimal2Sequence(String value, String unit) {
        if (value.contains(".")) {
            int PointIndex = value.indexOf(".");
            String intVal = value.substring(0, PointIndex);
            String decimal = value.substring(PointIndex + 1, PointIndex + 2);
            value = " . " + intVal + " " + unit + " " + decimal + " . ";
        }
        return value;
    }
}