Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String getStandardMobileFormat(String actualNumber) {
        String formattedNumber = null;
        if (actualNumber != null) {
            formattedNumber = actualNumber.replace("-", "");
            if (!formattedNumber.startsWith("+91")) {
                if (formattedNumber.startsWith("+1")) {
                    formattedNumber.replace("+", "+91");
                } else if (formattedNumber.startsWith("0")) {
                    formattedNumber = "+91" + formattedNumber.substring(1);// ignore 0 and start with +91
                } else {
                    formattedNumber = "+91" + formattedNumber;
                }
            }
        }

        return formattedNumber;
    }
}