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


Java NumberFormat.getPercentInstance方法代碼示例

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


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

示例1: toString

import java.text.NumberFormat; //導入方法依賴的package包/類
@Override
public String toString()
{
    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMinimumFractionDigits(2);
    StringBuilder sb = new StringBuilder();
    sb.append("UA: ");
    sb.append(percentFormat.format(getUA()));
    sb.append('\t');
    sb.append("LA: ");
    sb.append(percentFormat.format(getLA()));
    sb.append('\t');
    sb.append("DA: ");
    sb.append(percentFormat.format(getDA()));
    sb.append('\t');
    sb.append("sentences: ");
    sb.append(sentenceCount);
    sb.append('\t');
    sb.append("speed: ");
    sb.append(sentenceCount / (float)(System.currentTimeMillis() - start) * 1000);
    sb.append(" sent/s");
    return sb.toString();
}
 
開發者ID:priester,項目名稱:hanlpStudy,代碼行數:24,代碼來源:Evaluator.java

示例2: SPTBase

import java.text.NumberFormat; //導入方法依賴的package包/類
protected SPTBase(String phaseName, 
                  String[] bindingNames, 
                  String[] annotationTypes,
                  boolean debugMode,
                  boolean groupMatchingMode, 
                  MatchMode matchMode, 
                  Rule[] rules,
                  Predicate[][] predicatesByType) {
  percentFormat = NumberFormat.getPercentInstance();
  percentFormat.setMinimumFractionDigits(3);
  this.phaseName = phaseName;
  this.bindingNames = bindingNames;
  this.annotationTypes = annotationTypes;
  this.debugMode = debugMode;
  this.groupMatchingMode = groupMatchingMode;
  this.matchMode = matchMode;
  this.rules = rules;
  this.predicatesByType = predicatesByType;
}
 
開發者ID:victorward,項目名稱:recruitervision,代碼行數:20,代碼來源:SPTBase.java

示例3: testEquals

import java.text.NumberFormat; //導入方法依賴的package包/類
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    StandardPieItemLabelGenerator g1 = new StandardPieItemLabelGenerator();
    StandardPieItemLabelGenerator g2 = new StandardPieItemLabelGenerator();
    assertTrue(g1.equals(g2));
    assertTrue(g2.equals(g1));
    
    g1 = new StandardPieItemLabelGenerator(
        "{0}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()
    );
    assertFalse(g1.equals(g2));
    g2 = new StandardPieItemLabelGenerator(
        "{0}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()
    );
    assertTrue(g1.equals(g2));
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:19,代碼來源:StandardPieItemLabelGeneratorTests.java

示例4: percent2

import java.text.NumberFormat; //導入方法依賴的package包/類
public static String percent2(double p1, double p2)
{
	String str;
	double p3 = p1 / p2;
	NumberFormat nf = NumberFormat.getPercentInstance();
	nf.setMinimumFractionDigits(0);
	str = nf.format(p3);
	return str;
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:10,代碼來源:TDevice.java

示例5: percent2

import java.text.NumberFormat; //導入方法依賴的package包/類
public static String percent2(double p1, double p2) {
    String str;
    double p3 = p1 / p2;
    NumberFormat nf = NumberFormat.getPercentInstance();
    nf.setMinimumFractionDigits(0);
    str = nf.format(p3);
    return str;
}
 
開發者ID:FallenCrood,項目名稱:Review-,代碼行數:9,代碼來源:TDevice.java

示例6: onActivityCreate

import java.text.NumberFormat; //導入方法依賴的package包/類
@Override
protected void onActivityCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_rx_file_download);
    ButterKnife.bind(this);
    setTitle("文件下載");

    numberFormat = NumberFormat.getPercentInstance();
    numberFormat.setMinimumFractionDigits(2);

    checkSDCardPermission();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:RxFileDownloadActivity.java

示例7: onActivityCreate

import java.text.NumberFormat; //導入方法依賴的package包/類
@Override
protected void onActivityCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_form_upload);
    ButterKnife.bind(this);
    setTitle("文件上傳");

    numberFormat = NumberFormat.getPercentInstance();
    numberFormat.setMinimumFractionDigits(2);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:FormUploadActivity.java

示例8: onActivityCreate

import java.text.NumberFormat; //導入方法依賴的package包/類
@Override
protected void onActivityCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_file_download);
    ButterKnife.bind(this);
    setTitle("簡單文件下載");

    numberFormat = NumberFormat.getPercentInstance();
    numberFormat.setMinimumFractionDigits(2);

    checkSDCardPermission();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:SimpleDownloadActivity.java

示例9: getString

import java.text.NumberFormat; //導入方法依賴的package包/類
/**
 * Returns a {@code String} representation of the current progress.
 * By default, this returns a simple percentage {@code String} based on
 * the value returned from {@code getPercentComplete}.  An example
 * would be the "42%".  You can change this by calling {@code setString}.
 *
 * @return the value of the progress string, or a simple percentage string
 *         if the progress string is {@code null}
 * @see    #setString
 */
public String getString(){
    if (progressString != null) {
        return progressString;
    } else {
        if (format == null) {
            format = NumberFormat.getPercentInstance();
        }
        return format.format(new Double(getPercentComplete()));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:JProgressBar.java

示例10: CPUTestCase

import java.text.NumberFormat; //導入方法依賴的package包/類
/**
 * Creates a new instance of CPUTestCase
 */
public CPUTestCase(String name) {
    super(name);
    percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMaximumFractionDigits(1);
    percentFormat.setMinimumFractionDigits(0);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:CPUTestCase.java

示例11: percent

import java.text.NumberFormat; //導入方法依賴的package包/類
public static String percent(double p1, double p2) {
    String str;
    double p3 = p1 / p2;
    NumberFormat nf = NumberFormat.getPercentInstance();
    nf.setMinimumFractionDigits(2);
    str = nf.format(p3);
    return str;
}
 
開發者ID:yangxp108,項目名稱:MVPArms_Fragment-fragment,代碼行數:9,代碼來源:DeviceUtils.java

示例12: StandardPieItemLabelGenerator

import java.text.NumberFormat; //導入方法依賴的package包/類
/**
 * Creates an item label generator using default number formatters.
 */
public StandardPieItemLabelGenerator() {
    this(
        DEFAULT_SECTION_LABEL_FORMAT, 
        NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()
    );
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:10,代碼來源:StandardPieItemLabelGenerator.java

示例13: testPercentFormat

import java.text.NumberFormat; //導入方法依賴的package包/類
void testPercentFormat() {
    NumberFormat format = NumberFormat.getPercentInstance(Locale.US);
    TestFormattedTextField ftf = create(format);
    ftf.setValue(.34);

    System.err.println("Testing NumberFormat.getPercentInstance(Locale.US)");

    // test inserting individual characters
    ftf.test(0, 0, "1", .14);
    ftf.test(2, 0, "2", 1.42);
    ftf.test(1, 0, "0", 1.02);

    // test inserting several characters at once - e.g. from clipboard
    ftf.test(0, 0, "1024", 10.24);
    ftf.test(3, 0, "333", 103.33);
    ftf.test(6, 0, "77", 10333.77);
    ftf.test(4, 0, "99", 10399.77);
    ftf.test(6, 0, "00", 10390.07);

    // test inserting strings that contain some formatting
    ftf.test(0, 0, "2,2", 2290.07);
    ftf.test(2, 0, "2,2", 222.27);
    ftf.test(4, 0, "2,2", 222.22);
    ftf.test(6, 0, "33,33", 2222233.33);

    // test delete
    ftf.test(0, 0, DELETE, 222233.33);
    ftf.test(10, 0, DELETE, 222233.33);
    ftf.test(5, 0, DELETE, 22223.33);
    ftf.test(6, 0, DELETE, 2222.33);

    // test backspace
    ftf.test(0, 0, BACKSPACE, 2222.33);
    ftf.test(7, 0, BACKSPACE, 222.23);
    ftf.test(4, 0, BACKSPACE, 22.23);
    ftf.test(2, 0, BACKSPACE, 2.23);

    // test replacing selection
    ftf.test(0, 1, "555", 555.23);
    ftf.test(4, 2, "555", 5555.55);
    ftf.test(2, 3, "1", 551.55);
    ftf.test(3, 2, "6", 55.65);
    ftf.test(4, 2, "12", 556.12);
    ftf.test(3, 4, "0", 5.5);
    ftf.test(0, 3, "111222333444555", 1112223334445.55);

    // test deleting selection
    ftf.test(0, 2, DELETE, 12223334445.55);
    ftf.test(0, 3, BACKSPACE, 223334445.55);
    ftf.test(12, 2, DELETE, 2233344.45);
    ftf.test(9, 2, BACKSPACE, 22333.44);
    ftf.test(4, 3, DELETE, 223.44);
    ftf.test(1, 2, BACKSPACE, 23.44);
    ftf.test(3, 3, DELETE, .23);
    ftf.test(1, 2, BACKSPACE, .02);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:57,代碼來源:Test6462562.java

示例14: onBindViewHolder

import java.text.NumberFormat; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (position == 0) {
        HeaderHolder headerHolder = (HeaderHolder) holder;
        //專輯詳情
        Glide.with(mContext).load(mAlbum.getCoverUrlMiddle()).into(headerHolder.mIvAlbum);
        headerHolder.mTvAlbumTitle.setText(mAlbum.getAlbumTitle());
        LastUpTrack lastUptrack = mAlbum.getLastUptrack();
        StringBuilder sb = new StringBuilder();
        headerHolder.mTvLastTrack.setText(sb.append("更新至").append(TimeUtils.formatDate(new Date(lastUptrack.getCreatedAt()))).append("  ").append(lastUptrack.getTrackTitle()).toString());
        sb.setLength(0);
        headerHolder.mTvPlayCount.setText(sb.append(StringUtils.formPlayCount(mAlbum.getPlayCount())).append("次播放").toString());
        sb.setLength(0);
        headerHolder.mTvTrackCount.setText(sb.append(mAlbum.getIncludeTrackCount()).append("集").toString());
        //訂閱狀態
        boolean isSubscribe = mAlbumDao.isSubscribe(mAlbumId);
        headerHolder.mTvSubscribe.setText(isSubscribe ? "已訂閱" : "訂閱");
        LevelListDrawable ld = (LevelListDrawable) headerHolder.mTvSubscribe.getBackground();
        ld.setLevel(isSubscribe ? 1 : 0);

        if (mHistory != null) {
            headerHolder.mRlHistoryBox.setVisibility(View.VISIBLE);
            sb.setLength(0);
            headerHolder.mTvHistoryTitle.setText(sb.append("繼續播放:").append(mHistory.getTrackTitle()).toString());
            sb.setLength(0);
            NumberFormat nf = NumberFormat.getPercentInstance();
            //返回數的整數部分所允許的最大位數
            nf.setMaximumIntegerDigits(3);
            //返回數的小數部分所允許的最大位數
            nf.setMaximumFractionDigits(0);
            headerHolder.mTvProgress.setText(sb.append("已播  ").append(nf.format(mHistory.getBreakPos() / (double) mHistory.getDuration())).toString());
            headerHolder.mIvTingSwitch.setImageLevel((XmlyManager.get().isPlaying() && playTrackId == mHistory.getTrackId()) ? 1 : 0);
        } else {
            headerHolder.mRlHistoryBox.setVisibility(View.GONE);
        }

    } else {
        Track track = mTracks.get(position);
        TrackDetailHolder detailHolder = (TrackDetailHolder) holder;
        detailHolder.mTvTrackTitle.setText(track.getTrackTitle());
        detailHolder.mTvTrackTitle.setTextColor(track.getDataId() == playTrackId
                ? mContext.getResources().getColor(R.color.second_base_color)
                : mContext.getResources().getColor(R.color.new_text_color_first));
        detailHolder.mIvTingSwitch.setImageLevel(0);
        if (track.getDataId() == playTrackId)
            detailHolder.mIvTingSwitch.setImageLevel(XmlyManager.get().isPlaying() ? 1 : 0);
        detailHolder.mTvCreated.setText(TimeUtils.getInstance().getDateString(new Date(track.getCreatedAt())));
        detailHolder.mTvDuration.setText(new SimpleDate().formDuration(track.getDuration()));
    }
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:51,代碼來源:TingAlbumDetailAdapter.java

示例15: StandardPieSectionLabelGenerator

import java.text.NumberFormat; //導入方法依賴的package包/類
/**
 * Creates a new section label generator using 
 * {@link #DEFAULT_SECTION_LABEL_FORMAT} as the label format string, and 
 * platform default number and percentage formatters.
 */
public StandardPieSectionLabelGenerator() {
    this(DEFAULT_SECTION_LABEL_FORMAT, NumberFormat.getNumberInstance(), 
            NumberFormat.getPercentInstance());
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:10,代碼來源:StandardPieSectionLabelGenerator.java


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