为一个冗长的问题提前道歉.反馈在这里特别赞赏...
在我的工作中,我们做了很多与日期范围的事情(日期时间,如果你愿意).我们需要进行各种测量,比较两个日期之间的重叠等.我设计了一个接口,一个基类和几个派生类,它们满足了我迄今为止的需求:
除了它的基本要素之外,DatePeriod超类如下(省略了所有迷人的特性,这些特征是我们为什么需要这组类的基础......):
(Java伪代码):
class datePeriod implements IDatePeriod
protected Calendar periodStartDate
protected Calendar periodEndDate
public DatePeriod(Calendar startDate, Calendar endDate) throws DatePeriodPrecedenceException
{
periodStartDate = startDate
. . .
// Code to ensure that the endDate cannot be set to a date which
// precedes the start date (throws exception)
. . .
periodEndDate = endDate
{
public void setStartDate(Calendar startDate)
{
periodStartDate = startDate
. . .
// Code to ensure that the …Run Code Online (Sandbox Code Playgroud)