将工作时间添加到Java DateTime [英] Add business hours to Java DateTime
问题描述
对于问题跟踪系统,我需要计算请求的响应时间。响应时间的计时器只能在营业时间内运行。我应该使用什么算法/库来执行此任务? (当然,我知道关于Joda-Time或ObjectLab Kit,但是找不到任何帮助我的任务的东西,我错过了什么?)
示例: p>
- 营业时间:上午9点至下午5点(每天8小时)
- 最大响应时间:16小时
该方法可能如下所示:
DateTime calculateResponseTime(DateTime issueReportedAt)
我将给出一些可能的输入和结果作为示例:
- 2011-09-19,下午1:00 - > Wed,2011-09-21,1:00 pm
- 星期一,2011-09-19,6:05 pm - > Thu,2011-09-22,上午9:00
- 2011-09-23, 2:00 pm - >周二,2011-09-27,下午2:00
你可以查看 jBPM商业日历。
另一个库可让您配置银行假期,但它没有营业时间的概念。
For an issue tracking system I need to calculate the response time for a request. The timer for response time should only be running during business hours. What algorithm/library should I use for this task? (Sure thing, I know about Joda-Time or ObjectLab Kit, but couldn't find anything helping with my task. Am I missing something?)
Example:
- Business hours: 9am - 5pm (8 hours per day)
- Maximum response time: 16 hours
The method may look something like:
DateTime calculateResponseTime(DateTime issueReportedAt)
I'll give some possible inputs and results as example:
- Mon, 2011-09-19, 1:00pm -> Wed, 2011-09-21, 1:00pm
- Mon, 2011-09-19, 6:05pm -> Thu, 2011-09-22, 9:00am
- Fri, 2011-09-23, 2:00pm -> Tue, 2011-09-27, 2:00pm
You may take a look on the jBPM business calendar.
Another library allows you configure bank holidays but it doesn't have a notion of business hours.
这篇关于将工作时间添加到Java DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!