我如何处理我的数据库日期= 1456201899566(getTimeInMillis),我想从现在开始经过joda时间。谢谢你,抱歉我的英文不好
答案 0 :(得分:0)
您可以使用here
中的PeriodFormatter .Source Date mydate = new Date(TimeInMillis);//TimeInMillis is your value from database
DateTime mystartDate = new DateTime(mydate);
//DateTime mystartDate = new DateTime(1978, 3, 26, 12, 35, 0, 0);
DateTime now = new DateTime();
Period period = new Period(mystartDate , now);
PeriodFormatter formatter = new PeriodFormatterBuilder()
.appendSeconds().appendSuffix(" seconds ago\n")
.appendMinutes().appendSuffix(" minutes ago\n")
.appendHours().appendSuffix(" hours ago\n")
.appendDays().appendSuffix(" days ago\n")
.appendWeeks().appendSuffix(" weeks ago\n")
.appendMonths().appendSuffix(" months ago\n")
.appendYears().appendSuffix(" years ago\n")
.printZeroNever()
.toFormatter();
String elapsed = formatter.print(period);