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 ymd2Timestamp(String dateString) throws ParseException {
    String timeStamp = null;//w ww  . ja  v a  2s . com
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
    Date d;
    try {
        d = sdf.parse(dateString);
        long l = d.getTime() / 1000;
        timeStamp = String.valueOf(l);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return timeStamp;
}

From source file:Main.java

public static String isRoot() {
    int isRoot = 0;
    try {//from   ww  w . j av a  2s  .c o  m
        if (new File("/system/bin/su").exists() || new File("/system/xbin/su").exists()) {
            isRoot = 1;
        } else {
            isRoot = 0;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return String.valueOf(isRoot);
}

From source file:Main.java

/**
 * Join a bunch of objects into a string delimited by the separator
 *
 * @param sep//from   w  w w.j  ava 2  s  .  c o  m
 * @param c
 * @return
 */
public static String join(final String sep, final Collection<? extends Object> c) {
    if (c == null) {
        return null;
    }
    if (c.size() == 1) {
        return String.valueOf(c.iterator().next());
    }
    if (c.size() == 0) {
        return "";
    }
    final StringBuilder sb = new StringBuilder();
    String s = "";
    for (final Object o : c) {
        sb.append(s).append(String.valueOf(o));
        s = sep;
    }
    return sb.toString();
}

From source file:Main.java

public static void mergeParam(HashMap<String, Object> params, List<NameValuePair> valuePair) {
    if (params != null) {
        for (HashMap.Entry<String, Object> entry : params.entrySet()) {
            String key = entry.getKey();
            String value = String.valueOf(entry.getValue());
            valuePair.add(new BasicNameValuePair(key, value));
        }//from w ww .  j  ava2 s  . co  m
    }
}

From source file:Main.java

public static String hashString(String input) {
    MessageDigest md5;//from w  ww .  j  a v a  2s . c  o  m
    try {
        md5 = MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return String.valueOf(input.hashCode());
    }
    md5.update(input.getBytes());
    byte[] hash = md5.digest();
    return toHex(hash);
}

From source file:Main.java

public static String ymdhm2Timestamp(String dateString) throws ParseException {
    String timeStamp = null;//from  w w  w  .ja va  2 s.co  m
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH/mm");
    Date d;
    try {
        d = sdf.parse(dateString);
        long l = d.getTime() / 1000;
        timeStamp = String.valueOf(l);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return timeStamp;
}