Skip to content

Instantly share code, notes, and snippets.

View BenoitDuffez's full-sized avatar

Benoit Duffez BenoitDuffez

  • Kerlink
  • Los Angeles greater area, CA, USA
View GitHub Profile
watch -n 60 "curl -s https://play.google.com/store/devices?hl=en | tr '<' '\n' | tr '\240' ' ' | grep 'cover-image' | grep -oE 'alt=\"[^\"]+\"' | cut -c6\- | sed -e 's/.$//' | sort"
public static String getDeltaDateText(Context context, Calendar date) {
final String formattedDate;
if (date != null && date.getTimeInMillis() > 10000) {
long delta = (new GregorianCalendar().getTimeInMillis() - date.getTimeInMillis()) / 1000;
if (delta < 60) {
formattedDate = context.getString(R.string.time_delay_moments);
} else if (delta < 3600) {
formattedDate = MessageFormat.format(context.getString(R.string.time_delay_minutes), (int) (delta / 60));
} else if (delta < 3600 * 24) {
formattedDate = MessageFormat.format(context.getString(R.string.time_delay_hours), (int) (delta / 3600));