Example usage for java.lang String substring

List of usage examples for java.lang String substring

Introduction

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

Prototype

public String substring(int beginIndex, int endIndex) 

Source Link

Document

Returns a string that is a substring of this string.

Usage

From source file:Main.java

public static String getPeso(String peso) {
    if (peso != null)
        return peso.substring(1, 10) + " " + peso.substring(21, 23);
    return "";
}

From source file:Main.java

private static char getType(Object object) {
    if (isArray(object)) {
        String str = object.toString();
        return str.substring(str.lastIndexOf("[") + 1, str.lastIndexOf("[") + 2).charAt(0);
    }/*w w w . jav a 2  s . c  om*/
    return 0;
}

From source file:Main.java

public static String substring(String str, int start, int end) {
    return str.substring(start, end);
}

From source file:Main.java

public static Color hex2Rgb(String colorStr) {
    return new Color(Integer.valueOf(colorStr.substring(1, 3), 16),
            Integer.valueOf(colorStr.substring(3, 5), 16), Integer.valueOf(colorStr.substring(5, 7), 16));
}

From source file:Main.java

public static String getActivityName(Context context) {
    String contextString = context.toString();
    return contextString.substring(contextString.lastIndexOf(".") + 1, contextString.indexOf("@"));
}

From source file:Main.java

public static int extractSdkLevel(String content) {
    return Integer.parseInt(content.substring(content.indexOf("API ") + 4, content.indexOf(":")));
}

From source file:Main.java

/**
 * /*  w  ww  . jav a 2s  .co m*/
 *
 * @param propertyName
 * @return
 */
private static String getIsName(String propertyName) {
    String method = "is" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
    return method;
}

From source file:Main.java

public static int[] extractTimeDetailsFromString(String value) {

    int hour = Integer.parseInt(value.substring(0, value.indexOf(COLON)));

    int min = Integer.parseInt(value.substring(value.indexOf(COLON) + 1, value.length()));

    return new int[] { hour, min };
}

From source file:Main.java

public static String formatMobileNum(String str, int start, int end) {
    String subString = str.substring(start, end);
    return str.replace(subString, "****");
}

From source file:Main.java

public static String getUUID() {
    String uuid = UUID.randomUUID().toString();
    return uuid.substring(0, 8) + uuid.substring(9, 13) + uuid.substring(14, 18) + uuid.substring(19, 23)
            + uuid.substring(24);//from w  w w  . j  a v a  2  s .co  m
}