Java Long Number to Date convertDecimal(long l)

Here you can find the source of convertDecimal(long l)

Description

Converts a given number to a value in KiloByte.

License

Open Source License

Declaration

public static String convertDecimal(long l) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;

public class Main {
    private static DecimalFormat nf = new DecimalFormat();

    /**//from w  ww  .  j  a v a2  s  .c o  m
     * Converts a given number to a value in KiloByte. Also uses dots for 1000s.
     */
    public static String convertDecimal(long l) {
        long l2 = l / 1024;
        if (l2 == 0 && l != 0)
            l2 = 1;
        return nf.format(l2) + " KB";
    }
}

Related

  1. convertDate(long timestamp)
  2. convertDate(Long uTime, SimpleDateFormat dateFormat)
  3. convertDateFromLong(Long val)
  4. convertDateFromTimeStamp(long timeStamp, String dateFormat)
  5. convertDateToString(long value)
  6. converteDataStr2Long(String str)
  7. convertFromLongToString(SimpleDateFormat fm, long date)
  8. convertHours2DatetimeString(long nodeTaskCompleteTime)
  9. convertMillisecondToDateTimeString(long millisecond, String mark)