智能时间计算 [英] Smart time calculation

查看:101
本文介绍了智能时间计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找一些标准和算法(可能是库),以present当一些事件发生。我的意思是什么 - FO前。如果某人的消息后2分钟前 - 我想显示2分钟前,而不是完整的日期和时间12 09月13下午5点17分。然后小时后 - 一个小时前...

I'm looking for some standard and algorithm (may be library) to present when some event happens. What I mean - fo ex. if someone post message 2 minutes ago - I want to display "2 min ago" instead full date and time "12-sep-13 5:17 PM". Then after hour - "An hour ago" ...

我想知道的可能是存在一些标准 - 为前。 2天前 - 这是正确的,而是4天前​​我必须显示完整的日期。

I want to know may be exist some standard - for ex. "2 days ago" - it's correct, but instead "3 days ago" I must display full date.

可能有些人知道一些图书馆或使用自己的优雅算法结果如果您分享。 - 会有帮助(我不希望重塑自行车)

May be some one knows some library or use own elegant algorithm.
If you share it - will be helpful.(I don't want to reinvent the bicycle)

推荐答案

请检查该<一个href=\"http://stackoverflow.com/questions/2179644/how-to-calculate-elapsed-time-from-now-with-joda-time\">page
 这LIB( JodaTime )。这LIB不小,但也许它会帮助你。

Please check this page and this lib (JodaTime). This lib is not small but maybe it will help you.

这篇关于智能时间计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆