當前位置: 首頁>>代碼示例>>Java>>正文


Java Strings.format1Decimals方法代碼示例

本文整理匯總了Java中org.elasticsearch.common.Strings.format1Decimals方法的典型用法代碼示例。如果您正苦於以下問題:Java Strings.format1Decimals方法的具體用法?Java Strings.format1Decimals怎麽用?Java Strings.format1Decimals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.common.Strings的用法示例。


在下文中一共展示了Strings.format1Decimals方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toString

import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
@Override
public String toString() {
    long bytes = getBytes();
    double value = bytes;
    String suffix = "b";
    if (bytes >= ByteSizeUnit.C5) {
        value = getPbFrac();
        suffix = "pb";
    } else if (bytes >= ByteSizeUnit.C4) {
        value = getTbFrac();
        suffix = "tb";
    } else if (bytes >= ByteSizeUnit.C3) {
        value = getGbFrac();
        suffix = "gb";
    } else if (bytes >= ByteSizeUnit.C2) {
        value = getMbFrac();
        suffix = "mb";
    } else if (bytes >= ByteSizeUnit.C1) {
        value = getKbFrac();
        suffix = "kb";
    }
    return Strings.format1Decimals(value, suffix);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:24,代碼來源:ByteSizeValue.java

示例2: toString

import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
@Override
public String toString() {
    long singles = singles();
    double value = singles;
    String suffix = "";
    if (singles >= SizeUnit.C5) {
        value = petaFrac();
        suffix = "p";
    } else if (singles >= SizeUnit.C4) {
        value = teraFrac();
        suffix = "t";
    } else if (singles >= SizeUnit.C3) {
        value = gigaFrac();
        suffix = "g";
    } else if (singles >= SizeUnit.C2) {
        value = megaFrac();
        suffix = "m";
    } else if (singles >= SizeUnit.C1) {
        value = kiloFrac();
        suffix = "k";
    }

    return Strings.format1Decimals(value, suffix);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:25,代碼來源:SizeValue.java

示例3: toString

import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
@Override
public String toString() {
    long bytes = bytes();
    double value = bytes;
    String suffix = "b";
    if (bytes >= ByteSizeUnit.C5) {
        value = pbFrac();
        suffix = "pb";
    } else if (bytes >= ByteSizeUnit.C4) {
        value = tbFrac();
        suffix = "tb";
    } else if (bytes >= ByteSizeUnit.C3) {
        value = gbFrac();
        suffix = "gb";
    } else if (bytes >= ByteSizeUnit.C2) {
        value = mbFrac();
        suffix = "mb";
    } else if (bytes >= ByteSizeUnit.C1) {
        value = kbFrac();
        suffix = "kb";
    }
    return Strings.format1Decimals(value, suffix);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:24,代碼來源:ByteSizeValue.java

示例4: toString

import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
/**
 * Returns a {@link String} representation of the current {@link TimeValue}.
 *
 * Note that this method might produce fractional time values (ex 1.6m) which cannot be
 * parsed by method like {@link TimeValue#parse(String, String, int)}.
 */
@Override
public String toString() {
    if (duration < 0) {
        return Long.toString(duration);
    }
    long nanos = nanos();
    if (nanos == 0) {
        return "0s";
    }
    double value = nanos;
    String suffix = "nanos";
    if (nanos >= C6) {
        value = daysFrac();
        suffix = "d";
    } else if (nanos >= C5) {
        value = hoursFrac();
        suffix = "h";
    } else if (nanos >= C4) {
        value = minutesFrac();
        suffix = "m";
    } else if (nanos >= C3) {
        value = secondsFrac();
        suffix = "s";
    } else if (nanos >= C2) {
        value = millisFrac();
        suffix = "ms";
    } else if (nanos >= C1) {
        value = microsFrac();
        suffix = "micros";
    }
    return Strings.format1Decimals(value, suffix);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:39,代碼來源:TimeValue.java

示例5: toString

import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
@Override
public String toString() {
    if (duration < 0) {
        return Long.toString(duration);
    }
    long nanos = nanos();
    if (nanos == 0) {
        return "0s";
    }
    double value = nanos;
    String suffix = "nanos";
    if (nanos >= C6) {
        value = daysFrac();
        suffix = "d";
    } else if (nanos >= C5) {
        value = hoursFrac();
        suffix = "h";
    } else if (nanos >= C4) {
        value = minutesFrac();
        suffix = "m";
    } else if (nanos >= C3) {
        value = secondsFrac();
        suffix = "s";
    } else if (nanos >= C2) {
        value = millisFrac();
        suffix = "ms";
    } else if (nanos >= C1) {
        value = microsFrac();
        suffix = "micros";
    }
    return Strings.format1Decimals(value, suffix);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:33,代碼來源:TimeValue.java

示例6: toString

import org.elasticsearch.common.Strings; //導入方法依賴的package包/類
@Override
public String toString() {
    return "[" + nodeId + "][" + nodeName + "][" + path + "] free: " + new ByteSizeValue(getFreeBytes()) +
            "[" + Strings.format1Decimals(getFreeDiskAsPercentage(), "%") + "]";
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:6,代碼來源:DiskUsage.java


注:本文中的org.elasticsearch.common.Strings.format1Decimals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。