本文整理汇总了Java中java.text.NumberFormat.setMaximumIntegerDigits方法的典型用法代码示例。如果您正苦于以下问题:Java NumberFormat.setMaximumIntegerDigits方法的具体用法?Java NumberFormat.setMaximumIntegerDigits怎么用?Java NumberFormat.setMaximumIntegerDigits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.text.NumberFormat
的用法示例。
在下文中一共展示了NumberFormat.setMaximumIntegerDigits方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setNumberOfAgents
import java.text.NumberFormat; //导入方法依赖的package包/类
/**
* Sets the number of agents.
* @param noAgents the new number of agents
*/
public void setNumberOfAgents(Integer noAgents) {
String displayText = null;
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(5);
nf.setMaximumIntegerDigits(5);
nf.setGroupingUsed(false);
if (noAgents==null) {
displayText = " " + nf.format(0) + " " + Language.translate("Agenten") + " ";
} else {
displayText = " " + nf.format(noAgents) + " " + Language.translate("Agenten") + " ";
}
jLabelAgentCount.setText(displayText);
}
示例2: ajustVol
import java.text.NumberFormat; //导入方法依赖的package包/类
/**
* 调整音量
*
* @param increase true=增加百分之20 false=减少百分之20
*/
public String ajustVol(boolean increase, int progress) {
AudioManager mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
int currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
float max = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
currentVolume = (int) (currentVolume + max * (progress / 100.0f) * (increase ? 1 : -1));
if (currentVolume < 0)
currentVolume = 0;
else if (currentVolume > max)
currentVolume = (int) max;
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume, 0);
//弹出系统媒体音量调节框
mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
AudioManager.ADJUST_SAME, AudioManager.FLAG_PLAY_SOUND
| AudioManager.FLAG_SHOW_UI);
NumberFormat nf = NumberFormat.getPercentInstance();
//返回数的整数部分所允许的最大位数
nf.setMaximumIntegerDigits(3);
//返回数的小数部分所允许的最大位数
// nf.setMaximumFractionDigits(2);
return nf.format(currentVolume / max);
}
示例3: convertFloat
import java.text.NumberFormat; //导入方法依赖的package包/类
/**
* Convert a float to a string format
*
* @param f The float to convert
* @return The string formatted from the float
*/
private String convertFloat(float f) {
NumberFormat format = NumberFormat.getInstance();
format.setMinimumFractionDigits(2);
format.setMaximumFractionDigits(2);
format.setMinimumIntegerDigits(1);
format.setMaximumIntegerDigits(5);
return format.format(f);
}
示例4: setNumberOfContainer
import java.text.NumberFormat; //导入方法依赖的package包/类
/**
* Sets the number of container.
* @param noContainer the new number of container
*/
public void setNumberOfContainer(Integer noContainer) {
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(3);
nf.setMaximumIntegerDigits(3);
nf.setGroupingUsed(false);
String displaText = " " + nf.format(noContainer) + " " + Language.translate("Container") + " ";
jLabelContainerCount.setText(displaText);
}
示例5: createUUID
import java.text.NumberFormat; //导入方法依赖的package包/类
private Long createUUID(Long num, String day, Integer length) {
String id = String.valueOf(num);
if (id.length() < length) {
NumberFormat nf = NumberFormat.getInstance();
nf.setGroupingUsed(false);
nf.setMaximumIntegerDigits(length);
nf.setMinimumIntegerDigits(length);
id = nf.format(num);
}
return Long.parseLong(day + id);
}
示例6: getFireAtTime
import java.text.NumberFormat; //导入方法依赖的package包/类
/**
* Returns the fire time for the <CODE>NthIncludedDayTrigger</CODE> as a
* string with the format "HH:MM[:SS]", with HH representing the
* 24-hour clock hour of the fire time. Seconds are optional and their
* inclusion depends on whether or not they were provided to
* {@link #setFireAtTime(String)}.
*
* @return the fire time for the trigger
* @see #setFireAtTime(String)
*/
public String getFireAtTime() {
NumberFormat format = NumberFormat.getNumberInstance();
format.setMaximumIntegerDigits(2);
format.setMinimumIntegerDigits(2);
format.setMaximumFractionDigits(0);
return format.format(this.fireAtHour) + ":" +
format.format(this.fireAtMinute) + ":" +
format.format(this.fireAtSecond);
}
示例7: 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()));
}
}