如何在Java中计算“时间前”?在RubyonRails中,有一个功能允许您获取任何日期并打印“很久以前”。例如:8 minutes ago8 hours ago8 days ago8 months ago8 years ago在Java中有一种简单的方法吗?
4 回答

潇湘沐
TA贡献1816条经验 获得超6个赞
import org.ocpsoft.prettytime.PrettyTime;PrettyTime p = new PrettyTime();System.out.println(p.format(new Date()));// prints "moments ago"
PrettyTime p = new PrettyTime(new Locale("fr"));System.out.println(p.format(new Date()));// prints "à l'instant"
android.text.format.DateUtils
添加回答
举报
0/150
提交
取消