Java Utililty Methods Date Format As

List of utility methods to do Date Format As

Description

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

Method

Stringfmt(double d)
Format a double value to a String
return formatDouble(d);
Stringfmt(double num, int minIntDigits, int maxFracDigitis)
fmt
NumberFormat nf = NumberFormat.getInstance();
if (minIntDigits != -1) {
    nf.setMinimumIntegerDigits(minIntDigits);
if (maxFracDigitis != -1) {
    nf.setMaximumFractionDigits(maxFracDigitis);
return nf.format(num);
...
Stringfmt(long count)
fmt
return FORMAT.format(count);
Stringfmt(String pattern, Object... args)
fmt
return MessageFormat.format(pattern, args);
StringfmtBdToString(BigDecimal bd, DecimalFormat df)
fmt Bd To String
if (bd == null)
    return "";
return df.format(bd.doubleValue());
StringfmtDate(Date date)
fmt Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(date);
StringfmtDate(Date date)
fmt Date
if (null == date) {
    return null;
try {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
    return sdf.format(date);
} catch (Exception e) {
    return null;
...
StringfmtDateTime(final Date dateTime, final String simpleDateTimeFormat)
fmt Date Time
final SimpleDateFormat sdf = new SimpleDateFormat(simpleDateTimeFormat);
return sdf.format(dateTime);
StringfmtMsg(final String fmt, final String arg)
Format a message consisting of a format string
Object[] o = new Object[1];
o[0] = arg;
return MessageFormat.format(fmt, o);
doublefmtNumStringToDouble(String s)
fmt Num String To Double
double d = 0.0;
if (s == null || s.trim().length() == 0)
    return 0.0;
DecimalFormat DF_4_DP = new DecimalFormat("###,##0.0000");
DecimalFormat DF_2_DP = new DecimalFormat("###,##0.00");
DecimalFormat df = DF_2_DP;
try {
    d = df.parse(s).doubleValue();
...