Example usage for java.lang String valueOf

List of usage examples for java.lang String valueOf

Introduction

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

Prototype

public static String valueOf(double d) 

Source Link

Document

Returns the string representation of the double argument.

Usage

From source file:Main.java

public static String getVersionCode(Context context) {
    String versionStr = "";
    String pkName = context.getPackageName();
    try {/*w w w .jav  a  2 s. c o  m*/
        versionStr = String.valueOf(context.getPackageManager().getPackageInfo(pkName, 0).versionCode);
    } catch (Exception e) {
        versionStr = "1";
        e.printStackTrace();
    }
    return versionStr;
}

From source file:Main.java

public static String bytesToString(byte[] bytes) {
    StringBuilder sb = new StringBuilder(bytes.length);
    for (int i = 0; i < bytes.length; i++) {
        sb.append(String.valueOf(bytes[i])).append(" ");
    }//from   ww w  .  ja  v a2s . c o m
    return sb.toString();
}

From source file:Main.java

private static String reversal(String s) {
    String result = "";
    char[] cs = s.toCharArray();
    for (int i = cs.length - 1; i > -1; i--) {
        result += String.valueOf(cs[i]);
    }//from  w w w  . j ava  2 s  . c om
    return result;
}

From source file:Main.java

public static String pad(int c) {
    if (c >= 10)
        return String.valueOf(c);
    else/* ww w. j  a  va2 s. com*/
        return "0" + String.valueOf(c);
}

From source file:Main.java

/**
 * Builds String output of time in the style of: hrs H mins M
 *
 * @param millis/*  www. ja  v  a 2  s  .  c o m*/
 * @return
 */
public static String buildCardViewStyleTime(int millis) {
    return String.valueOf(calcHours(millis)) + "H " + String.valueOf(calcRemainderMins(millis)) + "M";
}

From source file:Main.java

public static String getTimestampDate(String dateString, String formatString) {
    SimpleDateFormat format = new SimpleDateFormat(formatString);
    try {//  www .java2 s.  c  o m
        return String.valueOf(format.parse(dateString).getTime());
    } catch (Exception e) {
        return "";
    }
}

From source file:Main.java

private static String[] get24HourArray() {
    final int SIZE = 24;
    String[] hour = new String[SIZE];
    int index;/*w  w w  .j a v a 2 s  .  c o m*/
    for (index = 0; index < SIZE; index++) {
        String indexValue = String.valueOf(index);
        if (indexValue.length() == 1) {
            indexValue = String.format("0%s", indexValue);
        }
        hour[index] = indexValue;
    }
    return hour;
}

From source file:Main.java

public final static <K, V> String keyJoin(Map<K, V> map, String separator) {
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<K, V> entry : map.entrySet()) {
        sb.append(String.valueOf(entry.getKey())).append(separator);
    }/*from  w  w  w. j a va 2 s.c  o m*/
    return sb.toString().substring(0, sb.toString().length() - separator.length());
}

From source file:Main.java

private static String pad(long l) {
    if (l >= 10)
        return String.valueOf(l);
    else/* w  ww  .j  a  va  2s  .  co  m*/
        return "0" + String.valueOf(l);
}

From source file:Main.java

public static String getMorse(char ch) {
    return morseTable.get(String.valueOf(ch));
}