List of usage examples for java.sql Date equals
public boolean equals(Object obj)
From source file:org.kuali.kfs.fp.document.AuxiliaryVoucherDocument.java
/** * This method checks if the given accounting period ends on the last day of the previous fiscal year * * @param acctPeriod accounting period to check * @return true if the accounting period ends with the fiscal year, false if otherwise *///from w w w .j av a2 s. c o m public boolean isEndOfPreviousFiscalYear(AccountingPeriod acctPeriod) { final UniversityDateService universityDateService = SpringContext.getBean(UniversityDateService.class); final Date firstDayOfCurrFiscalYear = new Date(universityDateService .getFirstDateOfFiscalYear(universityDateService.getCurrentFiscalYear()).getTime()); final Date periodClose = acctPeriod.getUniversityFiscalPeriodEndDate(); java.util.Calendar cal = new java.util.GregorianCalendar(); cal.setTime(periodClose); cal.add(java.util.Calendar.DATE, 1); return (firstDayOfCurrFiscalYear.equals(new Date(cal.getTimeInMillis()))); }
From source file:org.kuali.kra.award.timeandmoney.AwardDirectFandADistributionRuleImpl.java
/** * This is a helper method for doExistingFandADistributionDatesOverlap. *//*w w w . j a va 2 s . c om*/ boolean targetOverlapsWithExistingPeriods(AwardDirectFandADistribution thisAwardDirectFandADistribution, List<AwardDirectFandADistribution> thisAwardDirectFandADistributions, int currentIndex) { boolean invalid = false; Date testStartDate; Date testEndDate; Date startDate = thisAwardDirectFandADistribution.getStartDate(); Date endDate = thisAwardDirectFandADistribution.getEndDate(); int newCurrentIndex = 0; for (AwardDirectFandADistribution testAwardDirectFandADistribution : thisAwardDirectFandADistributions) { testStartDate = testAwardDirectFandADistribution.getStartDate(); testEndDate = testAwardDirectFandADistribution.getEndDate(); if (newCurrentIndex != currentIndex) { if (startDate.before(testEndDate) && startDate.after(testStartDate) || endDate.after(testStartDate) && endDate.before(testEndDate) || startDate.equals(testEndDate) || endDate.equals(testStartDate)) { invalid = true; break; } } newCurrentIndex++; } return invalid; }
From source file:org.kuali.coeus.propdev.impl.budget.hierarchy.ProposalBudgetHierarchyServiceImpl.java
protected int getCorrespondingParentPeriod(List<BudgetPeriod> oldBudgetPeriods, Budget childBudget) { int correspondingStart = -1; // using start date of first period as start date and end date of last period // as end because budget start and end are not particularly reliable Date childStart = childBudget.getBudgetPeriod(0).getStartDate(); Date parentStart = oldBudgetPeriods.get(0).getStartDate(); Date parentEnd = oldBudgetPeriods.get(oldBudgetPeriods.size() - 1).getEndDate(); // check that child budget starts somewhere during parent budget if (childStart.compareTo(parentStart) >= 0 && childStart.compareTo(parentEnd) < 0) { // check that child budget starts on one of the budget period starts List<BudgetPeriod> parentPeriods = oldBudgetPeriods; for (int i = 0; i < parentPeriods.size(); i++) { if (childStart.equals(parentPeriods.get(i).getStartDate())) { correspondingStart = i;//from w w w.java2 s . c o m break; } } } return correspondingStart; }
From source file:org.kuali.kra.budget.summary.BudgetSummaryServiceImpl.java
public boolean isLeapDaysInPeriod(Date sDate, Date eDate) { Date leapDate;//ww w .j a v a 2s.co m int sYear = getYear(sDate); int eYear = getYear(eDate); if (isLeapYear(sDate)) { Calendar c1 = Calendar.getInstance(); c1.clear(); c1.set(sYear, 1, 29); leapDate = new java.sql.Date(c1.getTime().getTime()); // start date is before 2/29 & enddate >= 2/29 if (sDate.before(leapDate)) { if (eDate.compareTo(leapDate) >= 0) { return true; } } else if (sDate.equals(leapDate)) { return true; } } else if (isLeapYear(eDate)) { Calendar c1 = Calendar.getInstance(); c1.set(eYear, 1, 29); leapDate = new java.sql.Date(c1.getTime().getTime()); if (eDate.compareTo(leapDate) >= 0) { return true; } } else { sYear++; while (eYear > sYear) { if (isLeapYear(sYear)) { return true; } sYear++; } } return false; }
From source file:org.kuali.coeus.common.budget.impl.summary.BudgetSummaryServiceImpl.java
@Override public boolean isLeapDaysInPeriod(Date sDate, Date eDate) { Date leapDate;/* w ww . jav a 2s . c o m*/ int sYear = getYear(sDate); int eYear = getYear(eDate); if (isLeapYear(sDate)) { Calendar c1 = Calendar.getInstance(); c1.clear(); c1.set(sYear, 1, 29); leapDate = new java.sql.Date(c1.getTime().getTime()); // start date is before 2/29 & enddate >= 2/29 if (sDate.before(leapDate)) { if (eDate.compareTo(leapDate) >= 0) { return true; } } else if (sDate.equals(leapDate)) { return true; } } else if (isLeapYear(eDate)) { Calendar c1 = Calendar.getInstance(); c1.set(eYear, 1, 29); leapDate = new java.sql.Date(c1.getTime().getTime()); if (eDate.compareTo(leapDate) >= 0) { return true; } } else { sYear++; while (eYear > sYear) { if (isLeapYear(sYear)) { return true; } sYear++; } } return false; }
From source file:org.kuali.ole.coa.document.validation.impl.AccountGlobalRule.java
/** * This method checks to see if any expiration date field rules were violated Loops through each detail object and calls * {@link AccountGlobalRule#checkExpirationDate(MaintenanceDocument, AccountGlobalDetail)} * // w w w.j a v a 2 s . c o m * @param maintenanceDocument * @return false on rules violation */ protected boolean checkExpirationDate(MaintenanceDocument maintenanceDocument) { LOG.info("checkExpirationDate called"); boolean success = true; Date newExpDate = newAccountGlobal.getAccountExpirationDate(); // If creating a new account if acct_expiration_dt is set and the fund_group is not "CG" then // the acct_expiration_dt must be changed to a date that is today or later if (ObjectUtils.isNotNull(newExpDate)) { if (ObjectUtils.isNotNull(newAccountGlobal.getSubFundGroup())) { if (!SpringContext.getBean(SubFundGroupService.class) .isForContractsAndGrants(newAccountGlobal.getSubFundGroup())) { if (!newExpDate.after(today) && !newExpDate.equals(today)) { putGlobalError(OLEKeyConstants.ERROR_DOCUMENT_ACCMAINT_EXP_DATE_TODAY_LATER); success &= false; } } } } // a continuation account is required if the expiration date is completed. success &= checkContinuationAccount(maintenanceDocument, newExpDate); for (AccountGlobalDetail detail : newAccountGlobal.getAccountGlobalDetails()) { success &= checkExpirationDate(maintenanceDocument, detail); } return success; }
From source file:org.kuali.kra.timeandmoney.web.struts.action.TimeAndMoneyAction.java
/** * Date changes in hierarchy view are captured here. If the transaction is a No Cost Extension, we report the transaction * details for display in history tab.//from w w w . jav a2 s.co m */ protected boolean inspectAndCaptureObligationExpirationDateChanges(TimeAndMoneyForm timeAndMoneyForm, Boolean isNoCostExtension, AwardAmountInfo aai, Integer index, Award award, TimeAndMoneyDocument timeAndMoneyDocument, Entry<String, AwardHierarchyNode> awardHierarchyNode, List<TransactionDetail> dateChangeTransactionDetailItems) { boolean needToSave = false; Date previousObligationExpirationDate = aai.getObligationExpirationDate(); Date currentObligationExpirationDate = timeAndMoneyForm.getAwardHierarchyNodeItems().get(index) .getObligationExpirationDate(); if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).isPopulatedFromClient() && currentObligationExpirationDate != null && !currentObligationExpirationDate.equals(previousObligationExpirationDate)) { // previousObligationExpirationDate is null if (isNoCostExtension && (previousObligationExpirationDate == null || currentObligationExpirationDate.after(previousObligationExpirationDate))) { aai = getNewAwardAmountInfoForDateChangeTransaction(aai, award, timeAndMoneyDocument.getDocumentNumber()); aai.setObligationExpirationDate(currentObligationExpirationDate); awardHierarchyNode.getValue().setObligationExpirationDate(currentObligationExpirationDate); award.getAwardAmountInfos().add(aai); TransactionDetail transactionDetail = createTransDetailForDateChanges(aai.getAwardNumber(), aai.getAwardNumber(), aai.getSequenceNumber(), timeAndMoneyDocument.getAwardNumber(), timeAndMoneyDocument.getDocumentNumber(), OBLIGATED_END_COMMENT); aai.setTransactionId(transactionDetail.getTransactionId()); dateChangeTransactionDetailItems.add(transactionDetail); } else { aai = getNewAwardAmountInfoForDateChangeTransaction(aai, award, timeAndMoneyDocument.getDocumentNumber()); aai.setObligationExpirationDate(currentObligationExpirationDate); awardHierarchyNode.getValue().setObligationExpirationDate(currentObligationExpirationDate); award.getAwardAmountInfos().add(aai); } needToSave = true; } else if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).isPopulatedFromClient() && currentObligationExpirationDate == null) { //FYI, this will show an error to the user, we are doing this such they can see the error, and that they had put in a null value awardHierarchyNode.getValue().setObligationExpirationDate(null); } //special case where a user can enter an invalid date that will throw a hard error. If the user tries to change that date back //to the original date, we need to capture that and change the value on the document which is the date value that gets validated //in save rules. if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate() != null && currentObligationExpirationDate != null && currentObligationExpirationDate.equals(previousObligationExpirationDate) && !currentObligationExpirationDate .equals(awardHierarchyNode.getValue().getObligationExpirationDate())) { awardHierarchyNode.getValue().setObligationExpirationDate(currentObligationExpirationDate); } return needToSave; }
From source file:org.kuali.ole.coa.document.validation.impl.AccountGlobalRule.java
/** * This method checks to see if the updated expiration is not a valid one Only gets checked for specific {@link SubFundGroup}s * /*from w ww. j av a 2 s . co m*/ * @param oldAccount * @param newAccountGlobal * @return true if date has changed and is invalid */ protected boolean isUpdatedExpirationDateInvalid(Account oldAccount, AccountGlobal newAccountGlobal) { Date oldExpDate = oldAccount.getAccountExpirationDate(); Date newExpDate = newAccountGlobal.getAccountExpirationDate(); // When updating an account expiration date, the date must be today or later // (except for C&G accounts). Only run this test if this maint doc // is an edit doc boolean expDateHasChanged = false; // if the old version of the account had no expiration date, and the new // one has a date if (ObjectUtils.isNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) { expDateHasChanged = true; } // if there was an old and a new expDate, but they're different else if (ObjectUtils.isNotNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) { if (!oldExpDate.equals(newExpDate)) { expDateHasChanged = true; } } // if the expiration date hasnt changed, we're not interested if (!expDateHasChanged) { return false; } // if a subFundGroup isnt present, we cannot continue the testing SubFundGroup subFundGroup = newAccountGlobal.getSubFundGroup(); if (ObjectUtils.isNull(subFundGroup)) { return false; } // get the fundGroup code String fundGroupCode = newAccountGlobal.getSubFundGroup().getFundGroupCode().trim(); // if the account is part of the CG fund group, then this rule does not // apply, so we're done if (SpringContext.getBean(SubFundGroupService.class) .isForContractsAndGrants(newAccountGlobal.getSubFundGroup())) { return false; } // at this point, we know its not a CG fund group, so we must apply the rule // expirationDate must be today or later than today (cannot be before today) if (newExpDate.equals(today) || newExpDate.after(today)) { return false; } else return true; }
From source file:org.kuali.kra.timeandmoney.web.struts.action.TimeAndMoneyAction.java
/** * Date changes in hierarchy view are captured here. If the transaction is a No Cost Extension, we report the transaction * details for display in history tab.//from www. j a va 2 s. c o m */ protected boolean inspectAndCaptureCurrentFundEffectiveDateChanges(TimeAndMoneyForm timeAndMoneyForm, Boolean isNoCostExtension, AwardAmountInfo aai, Integer index, Award award, TimeAndMoneyDocument timeAndMoneyDocument, Entry<String, AwardHierarchyNode> awardHierarchyNode, List<TransactionDetail> dateChangeTransactionDetailItems) { Date currentEffectiveDate = timeAndMoneyForm.getAwardHierarchyNodeItems().get(index) .getCurrentFundEffectiveDate(); Date previousEffectiveDate = aai.getCurrentFundEffectiveDate(); boolean needToSave = false; if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).isPopulatedFromClient() && currentEffectiveDate != null && !currentEffectiveDate.equals(previousEffectiveDate)) { //aai.getCurrentFundEffectiveDate == null and this throws a stack trace only when doign a before // if current transaction currentFEDate is < previosu trans currentFEDate if (isNoCostExtension && previousEffectiveDate != null && currentEffectiveDate.before(previousEffectiveDate)) { AwardAmountInfo tempAai = getNewAwardAmountInfoForDateChangeTransaction(aai, award, timeAndMoneyDocument.getDocumentNumber()); needToSave = true; aai = tempAai; aai.setCurrentFundEffectiveDate(currentEffectiveDate); awardHierarchyNode.getValue().setCurrentFundEffectiveDate(currentEffectiveDate); award.getAwardAmountInfos().add(aai); TransactionDetail transactionDetail = createTransDetailForDateChanges(aai.getAwardNumber(), aai.getAwardNumber(), aai.getSequenceNumber(), timeAndMoneyDocument.getAwardNumber(), timeAndMoneyDocument.getDocumentNumber(), OBLIGATED_START_COMMENT); aai.setTransactionId(transactionDetail.getTransactionId()); dateChangeTransactionDetailItems.add(transactionDetail); } else { AwardAmountInfo tempAai = getNewAwardAmountInfoForDateChangeTransaction(aai, award, timeAndMoneyDocument.getDocumentNumber()); needToSave = true; aai = tempAai; aai.setCurrentFundEffectiveDate(currentEffectiveDate); awardHierarchyNode.getValue().setCurrentFundEffectiveDate(currentEffectiveDate); award.getAwardAmountInfos().add(aai); } } else if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).isPopulatedFromClient() && currentEffectiveDate == null) { //FYI, this will show an erorr to the user, we are doing this such they can see the error, and that they had put in a null value awardHierarchyNode.getValue().setCurrentFundEffectiveDate(null); } //special case where a user can enter an invalid date that will throw a hard error. If the user tries to change that date back //to the original date, we need to capture that and change the value on the document which is the date value that gets validated //in save rules. if (timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate() != null && timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate() != null && timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate() .equals(aai.getCurrentFundEffectiveDate()) && !timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate() .equals(awardHierarchyNode.getValue().getCurrentFundEffectiveDate())) { awardHierarchyNode.getValue().setCurrentFundEffectiveDate( timeAndMoneyForm.getAwardHierarchyNodeItems().get(index).getCurrentFundEffectiveDate()); } return needToSave; }
From source file:org.kuali.kfs.coa.document.validation.impl.AccountGlobalRule.java
/** * This method checks to see if the updated expiration is not a valid one Only gets checked for specific {@link SubFundGroup}s * * @param oldAccount//from ww w .j a v a 2s.c om * @param newAccountGlobal * @return true if date has changed and is invalid */ protected boolean isUpdatedExpirationDateInvalid(Account oldAccount, AccountGlobal newAccountGlobal) { Date oldExpDate = oldAccount.getAccountExpirationDate(); Date newExpDate = newAccountGlobal.getAccountExpirationDate(); // When updating an account expiration date, the date must be today or later // (except for C&G accounts). Only run this test if this maint doc // is an edit doc boolean expDateHasChanged = false; // if the old version of the account had no expiration date, and the new // one has a date if (ObjectUtils.isNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) { expDateHasChanged = true; } // if there was an old and a new expDate, but they're different else if (ObjectUtils.isNotNull(oldExpDate) && ObjectUtils.isNotNull(newExpDate)) { if (!oldExpDate.equals(newExpDate)) { expDateHasChanged = true; } } // if the expiration date hasnt changed, we're not interested if (!expDateHasChanged) { return false; } // if a subFundGroup isnt present, we cannot continue the testing SubFundGroup subFundGroup = newAccountGlobal.getSubFundGroup(); if (ObjectUtils.isNull(subFundGroup)) { return false; } // get the fundGroup code String fundGroupCode = newAccountGlobal.getSubFundGroup().getFundGroupCode().trim(); // if the account is part of the CG fund group, then this rule does not // apply, so we're done if (SpringContext.getBean(SubFundGroupService.class) .isForContractsAndGrants(newAccountGlobal.getSubFundGroup())) { return false; } // at this point, we know its not a CG fund group, so we must apply the rule // expirationDate must be today or later than today (cannot be before today) if (newExpDate.equals(today) || newExpDate.after(today)) { return false; } else { return true; } }