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[] getOccupantsIdsArrayFromList(ArrayList<Integer> occupantsList) {
    String[] occupantsArray = new String[occupantsList.size()];
    for (int i = 0; i < occupantsList.size(); i++) {
        occupantsArray[i] = String.valueOf(occupantsList.get(i));
    }/* ww w  .  ja v  a  2 s.c  om*/
    return occupantsArray;
}

From source file:Main.java

public static String[] toStringArray(Object[] objs) {
    if (objs == null)
        return new String[] {};
    String[] strs = new String[objs.length];
    for (int i = 0; i < objs.length; i++) {
        strs[i] = String.valueOf(objs[i]);
    }//ww  w .j  a  v  a  2 s  . com
    return strs;
}

From source file:Main.java

public static Collection<String> convertLongsToStrings(Collection<Long> longs) {
    if (longs != null) {
        Collection<String> strings = new ArrayList<String>(longs.size());
        for (long longNumber : longs) {
            strings.add(String.valueOf(longNumber));
        }//from   w w w. jav  a  2 s.  c o  m
        return strings;
    }
    return null;
}

From source file:Main.java

public static Formatter getNumberPickFormater() {
    return new Formatter() {

        @Override/*  w ww .  j a v  a 2  s .co m*/
        public String format(int value) {
            if (value < 10) {
                return "0" + value;
            }
            return String.valueOf(value);
        }
    };
}

From source file:Main.java

public static String decSignedString(byte b) {
    return String.valueOf(b);
}

From source file:Main.java

/**
 * //from ww w  . j av a2s .  c  o m
 * @param HHmm
 * @return
 */
public static String to12Hours(String HHmm) {
    String[] t = HHmm.trim().split(":");
    int start = Integer.parseInt(t[0]);
    String a = "am";
    if (start > 12) {
        start -= 12;
        a = "pm";
    }
    return String.valueOf(start) + ":" + t[1] + a;
}

From source file:Main.java

public static Bitmap resizeImage(Bitmap image, int maxWidth, int maxHeight) {
    Log.d(TAG, "[AirImagePickerUtils] Entering resizeImage: " + String.valueOf(maxWidth) + " x "
            + String.valueOf(maxHeight));
    Bitmap result = image;//  w w w . j  a  v  a2  s .c  om
    // make sure that the image has the correct height
    if (image.getWidth() > maxWidth || image.getHeight() > maxHeight && maxWidth != -1 && maxHeight != -1) {
        float reductionFactor = Math.max(Float.valueOf(image.getWidth()) / maxWidth,
                Float.valueOf(image.getHeight()) / maxHeight);

        result = Bitmap.createScaledBitmap(image, (int) (image.getWidth() / reductionFactor),
                (int) (image.getHeight() / reductionFactor), true);
        Log.d(TAG, "[AirImagePickerUtils] resized image to: " + String.valueOf(result.getWidth()) + " x "
                + String.valueOf(result.getHeight()));
    }
    Log.d(TAG, "[AirImagePickerUtils] Exiting resizeImage");
    return result;
}

From source file:Main.java

public static int delete(SQLiteDatabase db, String name, int id) {
    String[] whereArgs = { String.valueOf(id) };
    return db.delete(name, "id = ?", whereArgs);
}

From source file:Main.java

public static void setTextView(View view, int id, Object text) {
    if (view != null) {
        TextView tv = (TextView) view.findViewById(id);
        if (tv != null && text != null) {
            tv.setText(String.valueOf(text));
        }//w ww. j  a  v  a  2s  .  com
    }
}

From source file:Main.java

public static String substring(String str, int toCount, String more) {
    int reInt = 0;
    String reStr = "";
    if (str == null)
        return "";
    char[] tempChar = str.toCharArray();
    for (int kk = 0; (kk < tempChar.length && toCount > reInt); kk++) {
        String s1 = String.valueOf(tempChar[kk]);
        byte[] b = s1.getBytes();
        reInt += b.length;/* www . j av a2  s  .  c  o m*/
        reStr += tempChar[kk];
    }
    if (toCount == reInt || (toCount == reInt - 1))
        reStr += more;
    return reStr;
}