Here you can find the source of formatTimeStampString(Context context, long when, boolean fullFormat)
public static String formatTimeStampString(Context context, long when, boolean fullFormat)
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.text.format.DateUtils; import android.text.format.Time; public class Main { public static String formatTimeStampString(Context context, long when, boolean fullFormat) { Time then = new Time(); then.set(when);//from ww w . j av a2 s . com 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 | DateUtils.FORMAT_SHOW_DATE; } else if (then.yearDay != now.yearDay) { format_flags |= DateUtils.FORMAT_SHOW_DATE; } else { format_flags |= DateUtils.FORMAT_SHOW_TIME; } if (fullFormat) { format_flags |= (DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); } return DateUtils.formatDateTime(context, when, format_flags); } }