Example usage for java.lang String length

List of usage examples for java.lang String length

Introduction

In this page you can find the example usage for java.lang String length.

Prototype

public int length() 

Source Link

Document

Returns the length of this string.

Usage

From source file:Main.java

public static boolean isValidPhone(String phone) {
    if (phone.length() < 8 || phone.length() > 13) {
        return false;
    } else {/*from   www  . j  a va  2 s . co m*/
        return true;
    }
}

From source file:Main.java

private static String pad(String hexString) {
    if (hexString.length() == 1)
        return "0" + hexString;
    return hexString;
}

From source file:Main.java

public static Boolean checTelPhone(String userName) {
    if (userName.length() >= 7 && userName.length() <= 11) {
        return true;
    }/* w w w . j a v a 2  s . com*/
    return false;
}

From source file:Main.java

public static String formattedDouble(double d) {
    String dS = "" + d;
    return dS.length() > 6 ? dS.substring(0, 6) : dS;
}

From source file:Main.java

public static String padZerosLeft(String s, int width) {
    String r = s;
    while (r.length() < width) {
        r = "0" + r;
    }/* ww w . j  a va2 s  . c  om*/
    return r;
}

From source file:Main.java

public static String formatBankCardNumbers(String number) {
    if (number.length() == 16) {
        return number.substring(0, 4) + " **** **** " + number.substring(13, 16);
    } else {//from   w  w  w . j av a2  s .  c  om
        return number;
    }
}

From source file:Main.java

public static boolean isTelefonoSizeValid(String telefono) {
    if (telefono.length() == 10) {
        return true;
    }/*w  w w  .j  a v a2s  . co m*/
    return false;
}

From source file:Main.java

public static String padLeft(String s, int n) {
    if (s.length() == 1)
        return String.format("%0s" + n + "s", s);
    else/*  w w w.  j  av a  2s  .c  o  m*/
        return "";
}

From source file:Main.java

public static String formatScore(String scror) {
    if (scror.length() == 1) {
        return scror + ".0";
    } else {//from   ww w. ja  v  a 2 s . c  o m
        return scror;
    }
}

From source file:Main.java

public static boolean isCard(String cardId) {
    if (cardId.length() == 16 || cardId.length() == 19) {

        return true;
    }/*from  ww  w .ja  va2  s  . c  o  m*/
    return false;
}