Example usage for java.lang Long toString

List of usage examples for java.lang Long toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Long 's value.

Usage

From source file:com.kcs.core.utilities.Utility.java

public static String getXmlLongString(Long o) {
    if (Utility.isNull(o) || o.longValue() == 0) {
        return StringUtil.BLANK;
    } else {/*from   w  ww.java  2 s.com*/
        return o.toString();
    }
}

From source file:com.tech.utils.CustomCollectionUtil.java

/**
 * Method to return comma separated value String for set of long values.
 * /*from  w w  w .ja  va  2  s.  co  m*/
 * @param itemSet
 * @return csvString
 */
public static String convertSetToString(Set<Long> set) {
    StringBuilder csvString = new StringBuilder();
    if (set != null && !set.isEmpty()) {
        for (Long item : set) {
            if (csvString.length() > 0) {
                csvString.append(COMMA_SEPARATOR);
                csvString.append(item.toString());
            } else {
                csvString.append(item.toString());
            }
        }
    }
    if (csvString.length() > 0) {
        return csvString.toString();
    } else {
        return BLANK_STRING;
    }
}

From source file:com.tech.utils.CustomCollectionUtil.java

public static String convertListToCSVString(List<Long> itemsList) {
    StringBuilder csvString = new StringBuilder();
    if (itemsList != null && !itemsList.isEmpty()) {
        for (Long item : itemsList) {
            if (csvString.length() > 0) {
                csvString.append(COMMA_SEPARATOR);
                csvString.append(item.toString());
            } else {
                csvString.append(item.toString());
            }/*from  w  w w . j  a v  a 2 s  .  c o  m*/
        }
    }
    return csvString.toString();
}

From source file:com.facebook.ads.sdk.AdAsyncRequest.java

public static AdAsyncRequest fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:com.github.jessemull.microflex.util.BigIntegerUtil.java

/**
 * Safely converts a number to a BigInteger. Loss of precision may occur. Throws
 * an arithmetic exception upon overflow.
 * @param    Object    object to parse//ww w.j av a2s  . co  m
 * @return             parsed object
 * @throws   ArithmeticException    on overflow
 */
public static BigInteger toBigInteger(Object obj) {

    /* Switch on class and convert to BigInteger */

    String type = obj.getClass().getSimpleName();
    BigInteger parsed;

    switch (type) {

    case "Byte":
        Byte by = (Byte) obj;
        parsed = new BigInteger(by.toString());
        break;

    case "Short":
        Short sh = (Short) obj;
        parsed = new BigInteger(sh.toString());
        break;

    case "Integer":
        Integer in = (Integer) obj;
        parsed = new BigInteger(in.toString());
        break;

    case "Long":
        Long lo = (Long) obj;
        parsed = new BigInteger(lo.toString());
        break;

    case "Float":
        Float fl = (Float) obj;
        parsed = new BigInteger(fl.toString());
        break;

    case "BigInteger":
        parsed = (BigInteger) obj;
        break;

    case "BigDecimal":
        parsed = ((BigDecimal) obj).toBigInteger();
        break;

    case "Double":
        Double db = (Double) obj;
        parsed = new BigInteger(db.toString());
        break;

    default:
        throw new IllegalArgumentException(
                "Invalid type: " + type + "\nData values " + "must extend the abstract Number class.");

    }

    return parsed;
}

From source file:com.github.jessemull.microflex.util.BigIntegerUtil.java

/**
 * Safely converts a number to a BigInteger. Loss of precision may occur. Throws
 * an arithmetic exception upon overflow.
 * @param    Number    object to parse/*from w  w w . j a  v  a  2  s.  co  m*/
 * @return             parsed object
 * @throws   ArithmeticException    on overflow
 */
public static BigInteger toBigInteger(Number number) {

    /* Switch on class and convert to BigInteger */

    String type = number.getClass().getSimpleName();
    BigInteger parsed;

    switch (type) {

    case "Byte":
        Byte by = (Byte) number;
        parsed = new BigInteger(by.toString());
        break;

    case "Short":
        Short sh = (Short) number;
        parsed = new BigInteger(sh.toString());
        break;

    case "Integer":
        Integer in = (Integer) number;
        parsed = new BigInteger(in.toString());
        break;

    case "Long":
        Long lo = (Long) number;
        parsed = new BigInteger(lo.toString());
        break;

    case "Float":
        Float fl = (Float) number;
        parsed = new BigInteger(fl.toString());
        break;

    case "BigInteger":
        parsed = (BigInteger) number;
        break;

    case "BigDecimal":
        parsed = ((BigDecimal) number).toBigInteger();
        break;

    case "Double":
        Double db = (Double) number;
        parsed = new BigInteger(db.toString());
        break;

    default:
        throw new IllegalArgumentException(
                "Invalid type: " + type + "\nData values " + "must extend the abstract Number class.");

    }

    return parsed;
}

From source file:org.opencastproject.remotetest.util.Utils.java

public static String schedulerEvent(Integer duration, String title, String id) throws Exception {
    Long start = System.currentTimeMillis() + 60000;
    Long end = start + duration;//from  w ww  . jav  a 2s  . com
    InputStream is = null;
    try {
        is = Utils.class.getResourceAsStream("/scheduler-event.xml");
        String event = IOUtils.toString(is, "UTF-8");
        return event.replace("@@id@@", id).replace("@@title@@", title).replace("@@start@@", start.toString())
                .replace("@@end@@", end.toString()).replace("@@duration@@", duration.toString());
    } finally {
        IOUtils.closeQuietly(is);
    }
}

From source file:com.facebook.ads.sdk.ProductFeedUploadError.java

public static ProductFeedUploadError fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:hoot.services.utils.DbUtils.java

private static long getNodeCountByMapName(Connection connection, String mapName, Expression<?> table) {
    long recordCount = 0;

    List<Long> mapIds = getMapIdsByName(connection, mapName);

    for (Long mapId : mapIds) {
        recordCount += new SQLQuery<>(connection, getConfiguration(mapId.toString())).from(table).fetchCount();
    }/*from w ww .  j ava 2  s  .  c  o  m*/

    return recordCount;
}

From source file:com.microsoft.azure.engagement.shared.EngagementDataPushReceiver.java

@TargetApi(9)
public static void addDataPush(Context context, String category, String body, boolean isBase64) {
    SharedPreferences settings = context.getSharedPreferences(ENGAGEMENT_PREFERENCES, 0/*MODE_PRIVATE*/);
    SharedPreferences.Editor prefEditor = settings.edit();

    Long tsLong = System.currentTimeMillis() / 1000;

    JSONObject json = new JSONObject();

    try {//from ww  w . j  a  v a  2  s  . c om
        json.put("isBase64", isBase64);
        if (category == null)
            json.put("category", JSONObject.NULL);
        else
            json.put("category", category);
        json.put("body", body);
    } catch (JSONException e) {
        Log.e(EngagementShared.LOG_TAG, "Cannot store push");
        return;
    }

    String ts = tsLong.toString();
    String value = json.toString(); //category+" "+body;
    prefEditor.putString(ts, value);
    prefEditor.apply();

    final int MAX_CHAR = 128;
    int maxLength = (value.length() < MAX_CHAR) ? value.length() : MAX_CHAR;
    Log.i(EngagementShared.LOG_TAG, "received data push (" + ts + ") : " + value.substring(0, maxLength));
}