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

StringgetCurrentFormatedDate()
get Current Formated Date
return formatDate(new Date());
StringgetCurrentMonth()
get Current Month
return getFormatCurrentTime("MM");
StringgetCurrentTime()
get Current Time
return getFormatDateTime(new Date(), "yyyy-MM-dd HH:mm:ss");
StringgetCurrentYear()
get Current Year
return getFormatCurrentTime("yyyy");
StringgetDateEN()
get Date in format of "yyyy-MM-dd HH:mm:ss"
SimpleDateFormat format1 = new SimpleDateFormat(
        "yyyy-MM-dd HH:mm:ss");
String date1 = format1.format(new Date(System.currentTimeMillis()));
return date1;
SimpleDateFormatgetDefaultFormatter(Date date)
Returns SimpleDateFormat instance that formats date in default application format (time only for recent dates, day and month for messages earlier than year and month/day/year for older)
try {
    Date now = new Date();
    if (now.before(date)) {
        return new SimpleDateFormat("MM/dd/yyyy h:mm:ss a",
                Locale.US);
    long ms = now.getTime() - date.getTime();
    long seconds = ms / 1000;
...
StringgetFormatCurrentAdd(int amount, String format)
get Format Current Add
Date d = getDateAdd(new Date(), amount);
return getFormatDateTime(d, format);
StringgetFormatCurrentTime(String format)
get Format Current Time
return getFormatDateTime(new Date(), format);
StringgetFormatCurrentTime(String format)
get Format Current Time
return getFormatDateTime(new Date(), format);
StringgetFormatDate(Date date)
get Format Date
return getFormatDateTime(date, "yyyy-MM-dd");