您要显示的内容称为相对时间显示。Android提供了显示相对于您当前时间的时间的方法。您不必为此目的而使用任何第三方库。
您可以使用
DateUtils.getRelativeTimeSpanString(long time, long now, long minResolution)
在这里参考文档
例如。
DateUtils.getRelativeTimeSpanString(your_time_in_milliseconds, current_ time_in_millisecinds,DateUtils.MINUTE_IN_MILLIS);
UPDATE1:
您可以尝试按照以下步骤传递日期并获取毫秒数。
public static long getDateInMillis(String srcDate) { SimpleDateFormat desiredFormat = new SimpleDateFormat( "d MMMM yyyy, hh:mm aa"); long dateInMillis = 0; try { Date date = desiredFormat.parse(srcDate); dateInMillis = date.getTime(); return dateInMillis; } catch (ParseException e) { Log.d("Exception while parsing date. " + e.getMessage()); e.printStackTrace(); } return 0; }希望对您有帮助。



