Example usage for java.lang Integer toString

List of usage examples for java.lang Integer toString

Introduction

In this page you can find the example usage for java.lang Integer toString.

Prototype

@HotSpotIntrinsicCandidate
public static String toString(int i) 

Source Link

Document

Returns a String object representing the specified integer.

Usage

From source file:Main.java

private static void saveMetadata(MediaMetadataRetriever metadataRetriever, HashMap<String, String> metadata,
        int metadataKey) {
    String value = metadataRetriever.extractMetadata(metadataKey);
    if (value != null)
        metadata.put(Integer.toString(metadataKey), value);
}

From source file:Main.java

public static String CalculatePraise(int num) {
    if (num > 1000) {
        double d = (double) num / 1000;
        DecimalFormat decimalFormat = new DecimalFormat("0.0");
        return decimalFormat.format(d) + "K";
    }//w  w  w  .j a  va 2s.c o m
    return Integer.toString(num);
}

From source file:Main.java

public static List<String> GetYearList(int count) {
    int year = Calendar.getInstance().get(Calendar.YEAR);

    List<String> yearList = new ArrayList<String>();

    for (int i = year - count; i <= year; i++) {
        yearList.add(Integer.toString(i));
    }/*ww  w  .j  ava 2  s .  c o  m*/

    return yearList;
}

From source file:Main.java

/**
 * Zero pad a number to a specified length
 *
 * @param buffer buffer to use for padding
 * @param value  the integer value to pad if necessary.
 * @param length the length of the string we should zero pad
 *//*ww  w.  j av a2  s.c o m*/
private static void padInt(StringBuilder buffer, int value, int length) {
    String strValue = Integer.toString(value);
    for (int i = length - strValue.length(); i > 0; i--) {
        buffer.append('0');
    }
    buffer.append(strValue);
}

From source file:Main.java

public static String getMetaString(ApplicationInfo appInfo, String key) {
    String value = "";

    if (appInfo == null)
        return value;

    value = String.valueOf(appInfo.metaData.get(key));
    if (TextUtils.isEmpty(value))
        value = Integer.toString(appInfo.metaData.getInt(key));

    return value;
}

From source file:Main.java

public static String cent2euro(int cent, boolean currency) {
    String s = Integer.toString(cent);
    while (s.length() < 3) {
        s = "0" + s;
    }/*from w  w w.  ja  v a 2  s .  com*/
    s = s.substring(0, s.length() - 2) + "," + s.substring(s.length() - 2, s.length());
    if (s.endsWith(",00")) {
        s = s.substring(0, s.length() - 2) + "-";
    }
    if (currency) {
        return s + " EUR";
    } else {
        return s;
    }
}

From source file:Main.java

/**
 * Shows a toast with the methane level// ww  w  .  java2  s .  c  o m
 *
 * @param methane the methane level
 *
 * @param context the context
 */
public static void showMethaneToast(Integer methane, Context context) {
    String message = "Methane level: " + Integer.toString(methane);
    Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static String nmtokenize(String cs) {
    StringBuilder s = new StringBuilder();
    for (int i = 0; i < cs.length(); i++) {
        char c = cs.charAt(i);
        if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_')
            s.append(c);//from   w w  w.j a v  a 2 s .c o  m
        else if (c != ' ')
            s.append("." + Integer.toString(c));
    }
    return s.toString();
}

From source file:Main.java

/**
 * Convert item reference number to string of length according to partition
 *
 * @param itemRefNo irn/*from   w w  w  . j a  va  2  s.  com*/
 * @param partition p
 * @return Item reference number string
 * @throws Exception
 */
private static String getItemRefNoString(int itemRefNo, byte partition) throws Exception {
    String result = Integer.toString(itemRefNo);
    int length;
    switch (partition) {
    case 0:
        length = 1;
        break;
    case 1:
        length = 2;
        break;
    case 2:
        length = 3;
        break;
    case 3:
        length = 4;
        break;
    case 4:
        length = 5;
        break;
    case 5:
        length = 6;
        break;
    case 6:
        length = 7;
        break;
    default:
        throw new Exception("Unknown partition: " + partition);
    }
    while (result.length() < length)
        result = "0" + result;
    return result;
}

From source file:Main.java

public static void addIntegerProperty(Document document, Element parent, String name, int value) {
    addPropertyNode(document, parent, name).setAttribute(INTEGER_ATTR, Integer.toString(value));
}