/** * Create a proper formatting instance with a custom number format for the * whole, numerator, and denominator. * @param format the custom format for the whole, numerator, and * denominator. */ public ProperBigFractionFormat(final NumberFormat format) { this(format, (NumberFormat)format.clone(), (NumberFormat)format.clone()); }
/** * Create a proper formatting instance with a custom number format for the * whole, numerator, and denominator. * @param format the custom format for the whole, numerator, and * denominator. */ public ProperFractionFormat(NumberFormat format) { this(format, (NumberFormat)format.clone(), (NumberFormat)format.clone()); }
/** * Create an improper formatting instance with a custom number format for * both the numerator and denominator. * @param format the custom format for both the numerator and denominator. */ protected AbstractFormat(final NumberFormat format) { this(format, (NumberFormat) format.clone()); }
/** * Convert the specified {@code count} into a human readable string. * @param count value to convert. * @return a readable string */ public static String readableCount(long count) { NumberFormat formatter = (NumberFormat) COUNT_FORMATTER.clone(); if (count < BOLD_COUNT_THRESHOLD) { return formatter.format(count); } else { return "<b>" + formatter.format(count) + "</b>"; } }
/** * Json输出格式的数字格式 * * @return 数字格式 */ public NumberFormat getNumberFormat() { NumberFormat nf = getAs(Function.numberFormat, NumberFormat.class); return nf == null ? null : (NumberFormat) nf.clone(); }
/** * Returns a new instance of {@code DateFormat} with the same properties. */ @Override public Object clone() { DateFormat clone = (DateFormat) super.clone(); clone.calendar = (Calendar) calendar.clone(); clone.numberFormat = (NumberFormat) numberFormat.clone(); return clone; }
/** * Convert the given size into a human readable string. * * NOTE: when changing the output of this function make sure to adapt the * jQuery tablesorter custom parsers in web/httpheader.jspf * * @param num size to convert. * @return a readable string */ public static String readableSize(long num) { float l = num; NumberFormat formatter = (NumberFormat) FORMATTER.clone(); if (l < 1024) { return formatter.format(l) + ' '; // for none-dirs append 'B'? ... } else if (l < 1048576) { return (formatter.format(l / 1024) + " KiB"); } else if (l < 1073741824) { return ("<b>" + formatter.format(l / 1048576) + " MiB</b>"); } else { return ("<b>" + formatter.format(l / 1073741824) + " GiB</b>"); } }
/** * Returns a new instance of {@code DecimalFormat} with the same pattern and * properties. */ @Override public Object clone() { DecimalFormat clone = (DecimalFormat) super.clone(); clone.ndf = (NativeDecimalFormat) ndf.clone(); clone.symbols = (DecimalFormatSymbols) symbols.clone(); return clone; }
/** * Returns a new instance of {@code ChoiceFormat} with the same ranges and * strings as this {@code ChoiceFormat}. * * @return a shallow copy of this {@code ChoiceFormat}. * * @see java.lang.Cloneable */ @Override public Object clone() { ChoiceFormat clone = (ChoiceFormat) super.clone(); clone.choiceLimits = choiceLimits.clone(); clone.choiceFormats = choiceFormats.clone(); return clone; }
jFormat = (NumberFormat) jFormat.clone();
/** * Constructs a parser using the specified set of symbols. * * @param symbols The set of symbols to use. */ public AbstractParser(final Symbols symbols) { this.symbols = symbols; this.numberFormat = (NumberFormat) symbols.numberFormat.clone(); if (SCIENTIFIC_NOTATION && numberFormat instanceof DecimalFormat) { final DecimalFormat numberFormat = (DecimalFormat) this.numberFormat; String pattern = numberFormat.toPattern(); if (pattern.indexOf("E0") < 0) { final int split = pattern.indexOf(';'); if (split >= 0) { pattern = pattern.substring(0, split) + "E0" + pattern.substring(split); } pattern += "E0"; numberFormat.applyPattern(pattern); } } }
/** * Creates a new instance of the formatter with the specified indentation width. The WKT will be * formatted on many lines, and the indentation width will have the value specified to this * constructor. If the specified indentation is {@link FormattableObject#SINGLE_LINE}, then the * whole WKT will be formatted on a single line. * * @param symbols The symbols. * @param indentation The amount of spaces to use in indentation. Typical values are 2 or 4. */ public Formatter(final Symbols symbols, final int indentation) { this.symbols = symbols; this.indentation = indentation; if (symbols == null) { throw new IllegalArgumentException( Errors.format(ErrorKeys.NULL_ARGUMENT_$1, "symbols")); } if (indentation < 0) { throw new IllegalArgumentException( Errors.format(ErrorKeys.ILLEGAL_ARGUMENT_$2, "indentation", indentation)); } numberFormat = (NumberFormat) symbols.numberFormat.clone(); buffer = new StringBuffer(); }
/** Returns the formatter. Creates it if needed. */ private Formatter getFormatter() { if (formatter == null) { if (SCIENTIFIC_NOTATION) { // We do not want to expose the "scientific notation hack" to the formatter. // TODO: Remove this block if some future version of J2SE 1.5 provides something // like 'allowScientificNotationParsing(true)' in DecimalFormat. formatter = new Formatter(symbols, (NumberFormat) symbols.numberFormat.clone()); } else { formatter = new Formatter(symbols, numberFormat); } } return formatter; }
/** * Create an instance with a custom imaginary character, and a custom number * format for both real and imaginary parts. * @param imaginaryCharacter The custom imaginary character. * @param format the custom format for both real and imaginary parts. */ public ComplexFormat(String imaginaryCharacter, NumberFormat format) { this(imaginaryCharacter, format, (NumberFormat)format.clone()); }
/** * Create a proper formatting instance with a custom number format for the * whole, numerator, and denominator. * @param format the custom format for the whole, numerator, and * denominator. */ public ProperBigFractionFormat(final NumberFormat format) { this(format, (NumberFormat)format.clone(), (NumberFormat)format.clone()); }
/** * Create an improper formatting instance with a custom number format for * both the numerator and denominator. * @param format the custom format for both the numerator and denominator. */ protected AbstractFormat(final NumberFormat format) { this(format, (NumberFormat) format.clone()); }
/** * Returns a clone of this instance. * * @return A clone. */ @Override public Object clone() { RelativeDateFormat clone = (RelativeDateFormat) super.clone(); clone.dayFormatter = (NumberFormat) this.dayFormatter.clone(); clone.secondFormatter = (NumberFormat) this.secondFormatter.clone(); return clone; }
/** * Json输出格式的数字格式 * * @return 数字格式 */ public NumberFormat getNumberFormat() { NumberFormat nf = getAs(Function.numberFormat, NumberFormat.class); return nf == null ? null : (NumberFormat) nf.clone(); }
/** * Returns a new instance of {@code DecimalFormat} with the same pattern and * properties. */ @Override public Object clone() { DecimalFormat clone = (DecimalFormat) super.clone(); clone.ndf = (NativeDecimalFormat) ndf.clone(); clone.symbols = (DecimalFormatSymbols) symbols.clone(); return clone; }
/** * Returns a new instance of {@code DecimalFormat} with the same pattern and * properties. */ @Override public Object clone() { DecimalFormat clone = (DecimalFormat) super.clone(); clone.ndf = (NativeDecimalFormat) ndf.clone(); clone.symbols = (DecimalFormatSymbols) symbols.clone(); return clone; }