List of utility methods to do Locale Format
String | formatPCT(Object num) Format percentage to two decimal places, like xx.xx%. String result; if (num instanceof Number) { Locale en = new Locale("en"); DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(en); df.applyPattern("0.00"); result = df.format(num) + "%"; } else { result = num.toString(); ... |
String | formatPersent(Object input) DOC Zqin Comment method "formatPersent". if (checkInput(input)) { Double db = new Double(input.toString()); DecimalFormat format = (DecimalFormat) DecimalFormat.getPercentInstance(Locale.ENGLISH); format.applyPattern("0.00%"); return format.format(db); return null; |
String | formatSmartDate(Date date) Format a date as returned for producing a portable player readable date. DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US); try { SimpleDateFormat simpleFormatter = (SimpleDateFormat) formatter; simpleFormatter.applyPattern("yy-MM-dd"); String result = simpleFormatter.format(date); return result; } catch (Exception e) { return ""; |
String | formatString(Object[] args) This method will format the message contained in the first element of the supplied array in the default locale return formatString(args, null);
|
String | formatString(String pattern, Object... args) Format using MesssageFormat but with the ROOT locale return new MessageFormat(pattern, Locale.ROOT).format(args); |
Date | formatString2Date(String dateString) format String Date SimpleDateFormat sdf = new SimpleDateFormat(); Date datum = new Date(); try { datum = sdf.parse(dateString); return datum; } catch (ParseException e) { return null; |
String | formattedFromDouble(double d, int scale, Locale locale) Convert from a BigDecimal forcing the scale. NumberFormat formatted = NumberFormat.getNumberInstance(locale);
formatted.setMaximumFractionDigits(scale);
formatted.setMinimumFractionDigits(scale);
return formatted.format(d);
|
String | formattedFromLong(long l, Locale locale) Convert from an long. return NumberFormat.getNumberInstance(locale).format(l);
|
double | formattedToDouble(String str, Locale loc) Convert to double from a formatted string. if (str.length() == 0) { str = "0"; return NumberFormat.getNumberInstance(loc).parse(str).doubleValue(); |
String | formatTime(Calendar calendar, String format) format Time return new SimpleDateFormat(format, Locale.getDefault()).format(calendar.getTime()); |