Android Utililty Methods Date Format

List of utility methods to do Date Format

Description

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

Method

StringFormatToString(Date date, String format)
Format To String
try {
    java.text.SimpleDateFormat sdf = new SimpleDateFormat(format);
    return sdf.format(date);
} catch (Exception e) {
    e.printStackTrace();
return "";
StringFormatToString(String date, String format)
Format To String
try {
    Date dt = DateTimeHelper.ParseStringToDate(date);
    java.text.SimpleDateFormat sdf = new SimpleDateFormat(format);
    return sdf.format(dt);
} catch (Exception e) {
    e.printStackTrace();
return date;
...
StringParseDateToString(Date date)
Parse Date To String
return ParseDateToString(date, "yyyy-MM-dd HH:mm:ss");
StringParseDateToString(Date date, String format)
Parse Date To String
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.format(date);
Stringdate(Date date)
date
return format(date, "yyyy-MM-dd");
Stringformat(Date date)
format
return format(date, "yyyy-MM-dd HH:mm");
Stringformat(Date date, String format)
format
if (date == null || format == null) {
    return "";
DateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
Stringformat(Date date, boolean isDateOnly)
format
if (isDateOnly) {
    return date(date);
} else {
    return format(date);
StringformatDA(Date d)
format DA
if (d == null)
    return null;
Calendar c = new GregorianCalendar();
c.setTime(d);
return formatDA(c, new StringBuffer(8)).toString();
StringformatDT(Date d)
format DT
if (d == null)
    return null;
Calendar c = new GregorianCalendar();
c.setTime(d);
StringBuffer sb = new StringBuffer(18);
formatDA(c, sb);
formatTM(c, sb);
return sb.toString();
...