Android Utililty Methods Long to Date Convert

List of utility methods to do Long to Date Convert

Description

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

Method

CharSequenceformatDateD(Context paramContext, long paramLong)
format Date D
return android.text.format.DateFormat.format("E", new Date(
        paramLong));
StringformatTimeStampString(Context context, long when, boolean fullFormat)
format Time Stamp String
Time then = new Time();
then.set(when);
Time now = new Time();
now.setToNow();
int format_flags = DateUtils.FORMAT_CAP_NOON_MIDNIGHT
        | DateUtils.FORMAT_CAP_AMPM;
if (then.year != now.year) {
    format_flags |= DateUtils.FORMAT_SHOW_YEAR
...
ArrayListgetDatesStartingFromToWithInterval( long startDate, long endDate, int dayInterval)
Return un ArrayList of Date objects from the starting date at the end date using the interval time from a date and the next one
ArrayList<Date> dates = new ArrayList<Date>();
Date date = new Date(startDate);
while ((date = addDays(date, dayInterval)).getTime() <= endDate) {
    dates.add(date);
return dates;
StringgetFormatDateString(String format, long date)
get Format Date String
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
        format);
return sdf.format(new java.util.Date(date));
StringgetLongFriendlyDate(long timeInMillis)
get Long Friendly Date
return getLongFriendlyDate(new Date(timeInMillis));
StringgetShortFriendlyDate(long timeInMillis)
get Short Friendly Date
return getShortFriendlyDate(new Date(timeInMillis));
StringgetTimeStringFrom(long timestamp)
get Time String From
if (timestamp <= 0)
    return "";
Date date = new Date(timestamp);
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm",
        Locale.getDefault());
return formatter.format(date);
StringhumanFriendlyDate(long time)
human Friendly Date
Date today = new Date();
Long duration = today.getTime() - time;
int second = 1000;
int minute = second * 60;
int hour = minute * 60;
int day = hour * 24;
if (duration < minute) {
    int n = (int) Math.floor(duration / second);
...
StringlongToDate(long timestamp)
long To Date
SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = new Date(timestamp);
return sfd.format(date1);
StringmillToDate(Long mill)
mill To Date
SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date1 = new Date(mill);
return sfd.format(date1);