Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    private static float getFloatFromString(String s) {
        if (s != null && !s.trim().equals("")) {
            s = s.replaceAll(",", "");

            try {
                if (s.endsWith("%")) {
                    return Float.valueOf(s.substring(0, s.length() - 1));
                } else {
                    return Float.valueOf(s);
                }
            } catch (NumberFormatException e) {
            }
        }

        return 0;
    }
}