Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.DecimalFormat;

public class Main {
    public static String formatedIntStringFromInput(String inputStr) {
        Long n = longFromString(inputStr);
        DecimalFormat df = new DecimalFormat("#,###");
        return df.format(n);
    }

    public static Long longFromString(String s) {
        s = s.replace(",", "").replace(".", "").replace(" ", "");
        try {
            return Long.valueOf(s);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0l;
    }
}