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, Locale locale)
format Date
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, locale);
return dateFormat.format(date);
Stringformat(Date d, String dateFormat)
format
final SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(d);
StringgetShortFriendlyDate(Date dt)
get Short Friendly Date
String dtStr = DateFormat.format("MMM d, yyyy", dt).toString();
Date today = getToday();
String todayStr = DateFormat.format("MMM d, yyyy", today)
        .toString();
if (dtStr.equals(todayStr)) {
    return "Today";
Date yesterday = getYesterday();
...
StringgetFormatDateString(String format)
get Format Date String
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
        format);
java.util.Date d = new java.util.Date();
return sdf.format(d);
StringgetFormatDateString(String format, java.util.Date date)
get Format Date String
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
        format);
return sdf.format(date);
StringgetFormatDateTime(String formatString, Date d)
get Format Date Time
SimpleDateFormat sdf = new SimpleDateFormat(formatString,
        Locale.ENGLISH);
return sdf.format(d);
StringformatDateToString(Date timestamp)
Konvertiert ein Date-Objekt in eine lesbare Zeitangabe (als String)
return new SimpleDateFormat(CLIENT_DATE_FORMAT).format(timestamp);
StringgetStringByFormat(Date date, String format)
get String By Format
SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format);
String strDate = null;
try {
    strDate = mSimpleDateFormat.format(date);
} catch (Exception e) {
    e.printStackTrace();
return strDate;
...
StringgetStringByFormat(Date date, String format)
get String By Format
SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format);
String strDate = null;
try {
    strDate = mSimpleDateFormat.format(date);
} catch (Exception e) {
    e.printStackTrace();
return strDate;
...
StringconvertDateToString(Date date)
convert Date To String
String result = "";
SimpleDateFormat format = new SimpleDateFormat(
        "yyyy-MM-dd HH:mm:ss");
try {
    result = format.format(date);
} catch (Exception e) {
    e.printStackTrace();
return result;