Here you can find the source of getShortFriendlyDate(long timeInMillis)
public static String getShortFriendlyDate(long timeInMillis)
//package com.java2s; import java.util.Calendar; import java.util.Date; import android.text.format.DateFormat; public class Main { public static String getShortFriendlyDate(Calendar cal) { return getShortFriendlyDate(cal.getTime()); }/*w w w.jav a2s . co m*/ public static String getShortFriendlyDate(long timeInMillis) { return getShortFriendlyDate(new Date(timeInMillis)); } public static String getShortFriendlyDate(Date dt) { 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(); String yesterdayStr = DateFormat.format("MMM d, yyyy", yesterday) .toString(); if (dtStr.equals(yesterdayStr)) { return "Yesterday"; } if (dt.getYear() != today.getYear()) { return dtStr; } else { return DateFormat.format("MMM d", dt).toString(); } } public static Date getToday() { Date now = new Date(); Date today = new Date(now.getYear(), now.getMonth(), now.getDate()); //beginning of today return today; } public static Date getYesterday() { Date today = getToday(); Date yesterday = new Date(today.getYear(), today.getMonth(), today.getDate() - 1); //beginning of yesterday return yesterday; } }