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 static String toString(long i) 

Source Link

Document

Returns a String object representing the specified long .

Usage

From source file:Main.java

public static float getDurationToFloat(long duration) {
    float f = 0;/*w w w . j  a  v a2  s  .c o m*/
    try {
        BigDecimal b = new BigDecimal(Long.toString(duration));
        BigDecimal one = new BigDecimal("1000");
        f = b.divide(one, 1, BigDecimal.ROUND_HALF_UP).floatValue();

    } catch (Exception e) {
        e.printStackTrace();
        f = 0;
    }
    return f;
}

From source file:Main.java

public static String getCreateTime() {
    String createtime = null;/*  w  ww.  j  av  a  2  s . co  m*/
    Calendar calendar = new GregorianCalendar();
    createtime = Long.toString(calendar.getTimeInMillis());
    return createtime;
}

From source file:Main.java

public static File createTempDir() throws IOException {
    File temp;//ww w  .j  a v  a2  s .co  m

    temp = File.createTempFile("encfs-java-tmp", Long.toString(System.nanoTime()));
    if (!temp.delete()) {
        throw new IOException("Could not delete temporary file " + temp.getAbsolutePath());
    }

    if (!temp.mkdir()) {
        throw new IOException("Could not create temporary directory");
    }

    return temp;
}

From source file:Main.java

public static String integerString(final Object value, final int desimals) {
    String str = Long.toString(((Number) value).longValue());
    if (desimals == 0 || str.length() == zeroes.length()) {
        return str;
    }/*from  ww  w.  j a  v a2 s  . c  om*/
    return zeroes.substring(0, desimals - str.length()) + str;
}

From source file:Main.java

/** Create a file Uri for saving an image*/
public static Uri getOutputMediaFileUri(long fileName) {
    return Uri.fromFile(getOutputMediaFile(Long.toString(fileName)));
}

From source file:Main.java

public static Intent launchEventById(long id) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri.Builder uri = Events.CONTENT_URI.buildUpon();
    uri.appendPath(Long.toString(id));
    intent.setData(uri.build());//w w  w  . ja  v a 2  s .  c  om
    return intent;
}

From source file:Main.java

public static void deleteComment(long companyId, SQLiteDatabase db) {
    db.delete(COMMENT_TABLE_NAME, COMMENT_COMPANY_ID + "=" + Long.toString(companyId), null);
}

From source file:Main.java

public static String getRightBoundNumber(long l, int length) {
    String s = Long.toString(l);
    while (s.length() < length) {
        s = " " + s;
    }/* w  ww . jav a 2  s .  co m*/
    return s;
}

From source file:Main.java

public static String formatSize(long size) {
    String suffix = null;/*from w w w.j ava  2  s . c o m*/

    if (size >= 1024) {
        suffix = "KB";
        size /= 1024;
        if (size >= 1024) {
            suffix = "MB";
            size /= 1024;
        }
    }

    StringBuilder resultBuffer = new StringBuilder(Long.toString(size));

    int commaOffset = resultBuffer.length() - 3;
    while (commaOffset > 0) {
        resultBuffer.insert(commaOffset, ',');
        commaOffset -= 3;
    }

    if (suffix != null)
        resultBuffer.append(suffix);
    return resultBuffer.toString();
}

From source file:Main.java

/**
 * /*from   w  w  w.ja v  a2s  .  c  o m*/
 */
protected static void decorateProperties(ThreadPoolExecutor executor, Properties properties) {
    if (executor != null) {
        if (properties != null) {
            properties.setProperty("thread-keep-alive-time",
                    Long.toString(executor.getKeepAliveTime(TimeUnit.MILLISECONDS)));

            properties.setProperty("thread-pool-size-largest", Integer.toString(executor.getLargestPoolSize()));

            properties.setProperty("thread-pool-size-minimum", Integer.toString(executor.getCorePoolSize()));

            properties.setProperty("thread-pool-size-maximum", Integer.toString(executor.getMaximumPoolSize()));

            properties.setProperty("thread-pool-size", Integer.toString(executor.getPoolSize()));

            properties.setProperty("runnable-completed-count", Long.toString(executor.getCompletedTaskCount()));

            properties.setProperty("runnable-active-count", Integer.toString(executor.getActiveCount()));

            properties.setProperty("queue-size", Integer.toString(executor.getQueue().size()));

            properties.setProperty("queue-capacity-remaining",
                    Integer.toString(executor.getQueue().remainingCapacity()));
        }
    }
}