java中人类友好的日期逻辑库
那么问题来了,是否有一个库可以让我以人类友好的格式做一些日期时间逻辑?例如,如果我想检查给定日期是否在下个月内,那么我将查询提交 if 语句 ${date} <= now + 1 个月,它将返回 true/false。基本思想是为 el 设计 jsp 标签或函数来进行日期操作并向客户端显示数据部分:
<bla:cond test="${datetime} <= now + 1 month">within next month</bla:cond>
<bla:cond test="${datetime} > now + 2 seconds && ${datetime} < now + 3 seconds">in 2 seconds</bla:cond>
类似的东西。这个想法是拥有一些易于更改/读取算术词典的日期时间逻辑。
提前致谢。
So a question, is there a library out there that will allow me to do some datetime logic in human friendly format? For example, if I want to check if given date is within next month then I'll query submit if statement ${date} <= now + 1 month and it'll return true/false. The basic idea is do design jsp tag or function for el to do date operations and display sections of data to the client:
<bla:cond test="${datetime} <= now + 1 month">within next month</bla:cond>
<bla:cond test="${datetime} > now + 2 seconds && ${datetime} < now + 3 seconds">in 2 seconds</bla:cond>
Something like that. The idea is to have some datetime logic with easy to change/read arithmetic lexicon.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用于日期算术的 joda-time 和用于人类友好显示的 pretty-time
joda-time for date arithmetic and pretty-time for human friendly display
人们通常会想到JodaTime。它还具有 JSP 标记库。
但我会在控制器中进行处理并仅在 JSP 中输出数据。
JodaTime is usually what comes to mind. It also has a JSP tag library.
But I'd do the processing in a Controller and output only data in the JSP.