Java Code Examples for java.text.NumberFormat#setMinimumIntegerDigits()
The following examples show how to use
java.text.NumberFormat#setMinimumIntegerDigits() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MCRAudioVideoExtender.java From mycore with GNU General Public License v3.0 | 5 votes |
/** * Returns the framerate formatted as a String, e. g. "25.0" * * @return the framerate formatted as a String, e. g. "25.0" */ public String getFrameRateFormatted() { // double r = (double)( Math.round( frameRate * 10.0 ) ) / 10.0; NumberFormat formatter = NumberFormat.getInstance(Locale.ROOT); formatter.setGroupingUsed(false); formatter.setMinimumIntegerDigits(2); formatter.setMinimumFractionDigits(1); formatter.setMaximumFractionDigits(1); return formatter.format(frameRate); }
Example 2
Source File: SystemProcessImpl.java From datacollector with Apache License 2.0 | 5 votes |
/** * @return a unique number which shorts in descending order */ private static String nextId() { NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumIntegerDigits(10); numberFormat.setGroupingUsed(false); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); return Utils.format("{}-{}", dateFormat.format(new Date()), numberFormat.format(fileCounter.incrementAndGet())); }
Example 3
Source File: MCRAudioVideoExtender.java From mycore with GNU General Public License v3.0 | 5 votes |
/** * Returns the duration of the asset, formatted as a timcode, e. g. * "01:15:00" for an asset thats duration is one hour and 15 minutes. * * @return the duration foramatted as a timecode like "hh:mm:ss" */ public String getDurationTimecode() { NumberFormat formatter = NumberFormat.getIntegerInstance(Locale.ROOT); formatter.setGroupingUsed(false); formatter.setMinimumIntegerDigits(2); return formatter.format(durationHours) + ":" + formatter.format(durationMinutes) + ":" + formatter.format( durationSeconds); }
Example 4
Source File: DailyCalendar.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Returns a string representing the properties of the * <CODE>DailyCalendar</CODE> * * @return the properteis of the DailyCalendar in a String format */ @Override public String toString() { NumberFormat numberFormatter = NumberFormat.getNumberInstance(); numberFormatter.setMaximumFractionDigits(0); numberFormatter.setMinimumIntegerDigits(2); StringBuffer buffer = new StringBuffer(); buffer.append("base calendar: ["); if (getBaseCalendar() != null) { buffer.append(getBaseCalendar().toString()); } else { buffer.append("null"); } buffer.append("], time range: '"); buffer.append(numberFormatter.format(rangeStartingHourOfDay)); buffer.append(":"); buffer.append(numberFormatter.format(rangeStartingMinute)); buffer.append(":"); buffer.append(numberFormatter.format(rangeStartingSecond)); buffer.append(":"); numberFormatter.setMinimumIntegerDigits(3); buffer.append(numberFormatter.format(rangeStartingMillis)); numberFormatter.setMinimumIntegerDigits(2); buffer.append(" - "); buffer.append(numberFormatter.format(rangeEndingHourOfDay)); buffer.append(":"); buffer.append(numberFormatter.format(rangeEndingMinute)); buffer.append(":"); buffer.append(numberFormatter.format(rangeEndingSecond)); buffer.append(":"); numberFormatter.setMinimumIntegerDigits(3); buffer.append(numberFormatter.format(rangeEndingMillis)); buffer.append("', inverted: " + invertTimeRange + "]"); return buffer.toString(); }
Example 5
Source File: Matrix.java From ph-commons with Apache License 2.0 | 5 votes |
/** * Print the matrix to the output stream. Line the elements up in columns with * a Fortran-like 'Fw.d' style format. * * @param aPW * Output stream. * @param nWidth * Column width. * @param nFractionDigits * Number of digits after the decimal. */ public void print (@Nonnull final PrintWriter aPW, @Nonnegative final int nWidth, @Nonnegative final int nFractionDigits) { final NumberFormat format = NumberFormat.getInstance (CGlobal.DEFAULT_LOCALE); format.setMinimumIntegerDigits (1); format.setMaximumFractionDigits (nFractionDigits); format.setMinimumFractionDigits (nFractionDigits); format.setGroupingUsed (false); print (aPW, format, nWidth + 2); }
Example 6
Source File: ApplicationId.java From hadoop with Apache License 2.0 | 5 votes |
@Override public NumberFormat initialValue() { NumberFormat fmt = NumberFormat.getInstance(); fmt.setGroupingUsed(false); fmt.setMinimumIntegerDigits(4); return fmt; }
Example 7
Source File: ApplicationAttemptId.java From big-c with Apache License 2.0 | 5 votes |
@Override public NumberFormat initialValue() { NumberFormat fmt = NumberFormat.getInstance(); fmt.setGroupingUsed(false); fmt.setMinimumIntegerDigits(6); return fmt; }
Example 8
Source File: Widget.java From mpcmaid with GNU Lesser General Public License v2.1 | 5 votes |
public void load() { final double tuning = getSampleElement().getTuning(); final NumberFormat decimalFormat = NumberFormat.getInstance(Locale.US); decimalFormat.setMinimumIntegerDigits(1); decimalFormat.setMaximumFractionDigits(2); getTextField().setText(decimalFormat.format(tuning)); }
Example 9
Source File: UtilAll.java From rocketmq with Apache License 2.0 | 5 votes |
public static String offset2FileName(final long offset) { final NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumIntegerDigits(20); nf.setMaximumFractionDigits(0); nf.setGroupingUsed(false); return nf.format(offset); }
Example 10
Source File: ContainerId.java From hadoop with Apache License 2.0 | 5 votes |
@Override public NumberFormat initialValue() { NumberFormat fmt = NumberFormat.getInstance(); fmt.setGroupingUsed(false); fmt.setMinimumIntegerDigits(6); return fmt; }
Example 11
Source File: UtilAll.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
public static String offset2FileName(final long offset) { final NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumIntegerDigits(20); nf.setMaximumFractionDigits(0); nf.setGroupingUsed(false); return nf.format(offset); }
Example 12
Source File: DLedgerUtils.java From openmessaging-storage-dledger with Apache License 2.0 | 5 votes |
public static String offset2FileName(final long offset) { NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumIntegerDigits(20); nf.setMaximumFractionDigits(0); nf.setGroupingUsed(false); return nf.format(offset); }
Example 13
Source File: Tools.java From andOTP with MIT License | 5 votes |
public static String formatTokenString(int token, int digits) { NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH); numberFormat.setMinimumIntegerDigits(digits); numberFormat.setGroupingUsed(false); return numberFormat.format(token); }
Example 14
Source File: ReservationId.java From big-c with Apache License 2.0 | 5 votes |
@Override public NumberFormat initialValue() { NumberFormat fmt = NumberFormat.getInstance(); fmt.setGroupingUsed(false); fmt.setMinimumIntegerDigits(4); return fmt; }
Example 15
Source File: UtilAll.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
/** * 将offset转化成字符串形式<br> * 左补零对齐至20位 */ public static String offset2FileName(final long offset) { final NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumIntegerDigits(20); nf.setMaximumFractionDigits(0); nf.setGroupingUsed(false); return nf.format(offset); }
Example 16
Source File: FileTablespace.java From tajo with Apache License 2.0 | 5 votes |
@Override public NumberFormat initialValue() { NumberFormat fmt = NumberFormat.getInstance(); fmt.setGroupingUsed(false); fmt.setMinimumIntegerDigits(2); return fmt; }
Example 17
Source File: PerfStatReader.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private static String convertTimestamp(long ms) { calendar.setTimeInMillis(ms); int hrs = calendar.get(Calendar.HOUR_OF_DAY); int mins = calendar.get(Calendar.MINUTE); int secs = calendar.get(Calendar.SECOND); NumberFormat nf = NumberFormat.getIntegerInstance(); nf.setMinimumIntegerDigits(2); return nf.format(hrs) + ":" + nf.format(mins) + ":" + nf.format(secs); }
Example 18
Source File: FileTablespace.java From tajo with Apache License 2.0 | 5 votes |
@Override public NumberFormat initialValue() { NumberFormat fmt = NumberFormat.getInstance(); fmt.setGroupingUsed(false); fmt.setMinimumIntegerDigits(6); return fmt; }
Example 19
Source File: MatrixUtil.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static float getDelta(Matrix4f left, Matrix4f right) { float delta = 0; final float d00 = left.m00 - right.m00; final float d01 = left.m01 - right.m01; final float d02 = left.m02 - right.m02; final float d03 = left.m03 - right.m03; final float d10 = left.m10 - right.m10; final float d11 = left.m11 - right.m11; final float d12 = left.m12 - right.m12; final float d13 = left.m13 - right.m13; final float d20 = left.m20 - right.m20; final float d21 = left.m21 - right.m21; final float d22 = left.m22 - right.m22; final float d23 = left.m23 - right.m23; final float d30 = left.m30 - right.m30; final float d31 = left.m31 - right.m31; final float d32 = left.m32 - right.m32; final float d33 = left.m33 - right.m33; delta += d00 + d01 + d02 + d03; delta += d10 + d11 + d12 + d13; delta += d20 + d21 + d22 + d23; delta += d30 + d31 + d32 + d33; NumberFormat format = NumberFormat.getInstance(); format.setMinimumFractionDigits(8); format.setMinimumIntegerDigits(3); System.out.println("[" + format.format(d00) + ", " + format.format(d10) + ", " + format.format(d20) + ", " + format.format(d30) + "]"); System.out.println("[" + format.format(d01) + ", " + format.format(d11) + ", " + format.format(d21) + ", " + format.format(d31) + "]"); System.out.println("[" + format.format(d02) + ", " + format.format(d12) + ", " + format.format(d22) + ", " + format.format(d32) + "]"); System.out.println("[" + format.format(d03) + ", " + format.format(d13) + ", " + format.format(d23) + ", " + format.format(d33) + "]"); System.out.println(); return delta; }
Example 20
Source File: FileOutputFormat.java From RDFS with Apache License 2.0 | 4 votes |
/** * Helper function to generate a name that is unique for the task. * * <p>The generated name can be used to create custom files from within the * different tasks for the job, the names for different tasks will not collide * with each other.</p> * * <p>The given name is postfixed with the task type, 'm' for maps, 'r' for * reduces and the task partition number. For example, give a name 'test' * running on the first map o the job the generated name will be * 'test-m-00000'.</p> * * @param conf the configuration for the job. * @param name the name to make unique. * @return a unique name accross all tasks of the job. */ public static String getUniqueName(JobConf conf, String name) { int partition = conf.getInt("mapred.task.partition", -1); if (partition == -1) { throw new IllegalArgumentException( "This method can only be called from within a Job"); } String taskType = (conf.getBoolean("mapred.task.is.map", true)) ? "m" : "r"; NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumIntegerDigits(5); numberFormat.setGroupingUsed(false); return name + "-" + taskType + "-" + numberFormat.format(partition); }