Here you can find the source of calculatorDaysAgo(String date, Locale locale, String format)
public static long calculatorDaysAgo(String date, Locale locale, String format)
import android.annotation.SuppressLint; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Locale; public class Main{ //w w w .j a v a 2s . co m public static long calculatorDaysAgo(String date, Locale locale, String format) { Calendar today = Calendar.getInstance(); Calendar cal = Calendar.getInstance(); SimpleDateFormat formatter = new SimpleDateFormat(format, locale); try { cal.setTime(formatter.parse(date)); } catch (ParseException e) { DebugLog.e("ParseException"); return 0; } return (today.getTimeInMillis() - cal.getTimeInMillis()) / (24 * 60 * 60 * 1000); } }