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

Stringformat(Date date, String pattern, Locale locale)
format
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern, locale);
String format = simpleDateFormat.format(date);
return format;
Stringformat(Date inputDate, String format, Locale locale)
Formats the date input to String using the format given.
SimpleDateFormat formatter = null;
try {
    formatter = new SimpleDateFormat(format, locale);
    return formatter.format(inputDate);
} catch (Exception ex) {
    formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT,
            Locale.US);
    return formatter.format(inputDate);
...
Stringformat(double d)
Formats a double.
NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH);
nf.setMinimumFractionDigits(6);
nf.setMaximumFractionDigits(6);
return nf.format(d);
Stringformat(Double d)
format
if (Double.isNaN(d)) {
    return "NaN     ";
if (Math.abs(d) > 1e-4 || d == 0) {
    DecimalFormat f = new DecimalFormat("#0.######", new DecimalFormatSymbols(Locale.US));
    String str = f.format(d);
    if (str.length() > 8) {
        str = str.substring(0, 8);
...
Stringformat(Double number)
format
return NUMBER_FORMAT.format(number);
doubleformat(double number)
format
synchronized (formatter) {
    return new Double(formatter.format(number));
Stringformat(double number, int fractionDigits)
format
return numberFormat(fractionDigits, Locale.US).format(number);
Stringformat(double value)
format
return NumberFormat.getInstance(Locale.US).format(value);
Stringformat(double values, boolean doNotFormat)
format
if (!doNotFormat) {
    Locale currentLocale = Locale.US;
    NumberFormat numberFormatter = NumberFormat.getNumberInstance(currentLocale);
    numberFormatter.setMinimumFractionDigits(0);
    numberFormatter.setMaximumFractionDigits(2);
    return numberFormatter.format(values);
} else {
    return Double.toString(values);
...
Stringformat(final Date date, final String format)
Format a date object into a date String using a given date format.
DateFormat dateFormat = new SimpleDateFormat(format, Locale.getDefault());
return dateFormat.format(date);