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

StringformatDate(Date date, String pattern)
Formats a date into a date/time string using the default TimeZone for this host.
return formatDate(date, pattern, TimeZone.getDefault());
StringformatDate(Date date, String pattern)
Formats the given date according to the specified pattern.
if (date == null)
    throw new IllegalArgumentException("date is null");
if (pattern == null)
    throw new IllegalArgumentException("pattern is null");
SimpleDateFormat formatter = DateFormatHolder.formatFor(pattern);
return formatter.format(date);
StringformatDate(Date date, String pattern)
Formats the given date according to the specified pattern.
if (date == null)
    throw new IllegalArgumentException("date is null");
if (pattern == null)
    throw new IllegalArgumentException("pattern is null");
SimpleDateFormat formatter = DateFormatHolder.formatFor(pattern);
return formatter.format(date);
StringformatDate(Date date, String pattern, TimeZone zone)
Formats a date into a date/time string
DateFormat dfmt = new SimpleDateFormat(pattern);
dfmt.setTimeZone(zone);
return dfmt.format(date);
StringformatDate(Date time)
Formats date to the string with default time date format.
SimpleDateFormat dateformat = new SimpleDateFormat(
        DEFAULT_TIME_DATE_FORMAT);
return dateformat.format(time);
StringformatDate(SimpleDateFormat s, Date d)
format Date
return s.format(d);
StringformatDate(String date)
format Date, "yyyy/MM/dd"
SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE_YYYY_MM_DD);
String newKey;
if (StringUtils.isEmpty(date) || date.equals("0")) {
    return "";
} else {
    newKey = date;
Date dt = new Date(Long.parseLong(newKey));
...
StringformatDate(long millis)
format Date
if (millis == 0)
    return "";
SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE_YYYY_MM_DD2);
Date dt = new Date(millis);
String sDateTime = null;
sDateTime = sdf.format(dt);
return sDateTime;
StringformatDate1(String date)
format Date, "yyyy-MM-dd"
SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE_YYYY_MM_DD);
String newKey;
if (StringUtils.isEmpty(date)) {
    newKey = "";
} else {
    newKey = date;
Date dt = new Date(Long.parseLong(newKey));
...
StringformatDateAndTime(long millis)
format Date And Time, "yyyy-MM-dd HH:mm"
if (millis == 0)
    return "";
SimpleDateFormat sdf = new SimpleDateFormat(
        FORMAT_DATE_AND_TIME_YYYY_MM_DD_HH_MM);
Date dt = new Date(millis);
String sDateTime = null;
sDateTime = sdf.format(dt);
return sDateTime;
...