Java Utililty Methods Locale Format

List of utility methods to do Locale Format

Description

The list of methods to do Locale Format are organized into topic(s).

Method

StringformatTime(final double theTime)
Formats the given time into a more readable string for printing, debugging, etc.
int hours = (int) (theTime / 3600);
int minutes = (int) (theTime / 60) % 60;
int seconds = (int) theTime % 60;
int milli = (int) (theTime * 1000) % 1000;
return nf(hours, 2) + ":" + nf(minutes, 2) + ":" + nf(seconds, 2) + "." + nf(milli, 3);
StringBuilderformatTo(StringBuilder buf, int[] d, String sep)
Formats the int array d.
if (d == null) {
    return buf.append("null");
if (d.length == 0) {
    return buf;
buf.append(d[0]);
for (int i = 1; i < d.length; i++) {
...
StringformatToString(double num, int decPlaces)
Returns the supplied number formatted as a string with the given number of decimal places fixed and padded with zeroes if needed.
NumberFormat nf = NumberFormat.getNumberInstance();
if (Math.abs(num) >= 1.0E9) {
    try { 
        ((DecimalFormat) nf).applyPattern("0.###E0");
    } catch (Exception e) {
nf.setGroupingUsed(false);
...
StringformatValues(double x, double y)
format Values
NumberFormat nf = nfCoordRound.get();
return nf.format(x) + " " + nf.format(y);
StringformatZahl(Number nZahl, int iNachkommastellen, Locale locale)
Eine Zahl localeabhaengig formatieren.
if (nZahl instanceof Integer) {
    return nZahl.toString();
NumberFormat nf = NumberFormat.getNumberInstance(locale);
nf.setMaximumFractionDigits(iNachkommastellen);
nf.setMinimumFractionDigits(iNachkommastellen);
return nf.format(nZahl.doubleValue());