use of org.kuali.kfs.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.
the class CuContractsGrantsInvoiceDocumentAction method parseDateRange.
private Pair<Date, Date> parseDateRange(String dateRange) throws ParseException {
if (StringUtils.length(dateRange) != CuArConstants.CINV_DATE_RANGE_EXPECTED_FORMAT_LENGTH) {
dateRange = StringUtils.defaultString(dateRange);
String errorMessage = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(CUKFSKeyConstants.WARNING_CINV_DATE_RANGE_INVALID_FORMAT_LENGTH);
throw new ParseException(MessageFormat.format(errorMessage, new String[] { dateRange }), 0);
}
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
Date startDate = dateTimeService.convertToSqlDate(dateRange.substring(CuArConstants.CINV_DATE_RANGE_START_DATE_START_INDEX, CuArConstants.CINV_DATE_RANGE_START_DATE_END_INDEX));
Date endDate = dateTimeService.convertToSqlDate(dateRange.substring(CuArConstants.CINV_DATE_RANGE_END_DATE_START_INDEX));
return Pair.of(startDate, endDate);
}
use of org.kuali.kfs.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.
the class DisencumbranceEnterpriseFeederFileSetType method getFileName.
/**
* Return the file name based on information from user and file user identifier
*
* @param user Person object representing user who uploaded file
* @param fileUserIdentifer String representing user who uploaded file
* @return String enterprise feeder formated file name string using information from user and file user identifier
* @see org.kuali.kfs.sys.batch.BatchInputFileSetType#getFileName(java.lang.String, org.kuali.kfs.kim.bo.Person,
* java.lang.String)
*/
public String getFileName(String fileType, String principalName, String fileUserIdentifer, Date creationDate) {
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
StringBuilder buf = new StringBuilder();
fileUserIdentifer = StringUtils.deleteWhitespace(fileUserIdentifer);
fileUserIdentifer = StringUtils.remove(fileUserIdentifer, FILE_NAME_PART_DELIMITER);
buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(principalName).append(FILE_NAME_PART_DELIMITER).append(fileUserIdentifer).append(FILE_NAME_PART_DELIMITER).append(dateTimeService.toDateTimeStringForFilename(creationDate)).append(getFileExtension(fileType));
return buf.toString();
}
use of org.kuali.kfs.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.
the class VendorRule method validateDOBDate.
protected boolean validateDOBDate(VendorDetail vDetail) {
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
Date today = dateTimeService.getCurrentDate();
if (ObjectUtils.isNotNull(vDetail.getVendorHeader().getVendorDOB())) {
Date dobDate = vDetail.getVendorHeader().getVendorDOB();
if (ObjectUtils.isNotNull(dobDate) && today.compareTo(dobDate) <= 0) {
putFieldError(VendorPropertyConstants.VENDOR_DOB, VendorKeyConstants.ERROR_VENDOR_W8ANDW9_SIGNED_AFTER_TODAY);
return false;
}
}
return true;
}
use of org.kuali.kfs.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.
the class VendorRule method validateW8SignedDate.
protected boolean validateW8SignedDate(VendorDetail vDetail) {
if (ObjectUtils.isNotNull(vDetail.getVendorHeader().getVendorW8BenReceivedIndicator()) && vDetail.getVendorHeader().getVendorW8BenReceivedIndicator()) {
if (SpringContext.getBean(ParameterService.class).getParameterValueAsBoolean(VendorDetail.class, VendorParameterConstants.W8_DATA_REQUIRED_IND)) {
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
Date today = dateTimeService.getCurrentDate();
if (ObjectUtils.isNotNull(vDetail.getVendorHeader().getVendorW8SignedDate())) {
Date signedDate = vDetail.getVendorHeader().getVendorW8SignedDate();
if (today.compareTo(signedDate) <= 0) {
putFieldError(VendorPropertyConstants.VENDOR_W8SIGNED_DATE, VendorKeyConstants.ERROR_VENDOR_W8ANDW9_SIGNED_AFTER_TODAY);
return false;
}
} else {
putFieldError(VendorPropertyConstants.VENDOR_W8SIGNED_DATE, VendorKeyConstants.ERROR_VENDOR_W8SINGED_DATE_REQUIRED);
return false;
}
}
}
return true;
}
use of org.kuali.kfs.core.api.datetime.DateTimeService in project cu-kfs by CU-CommunityApps.
the class VendorRule method validateVendorWithholdingTaxDates.
/**
* Validates the rule that if a document has a federal withholding tax begin date and end date, the begin date
* should come before the end date.
*
* @param vdDocument VendorDetail
* @return boolean false or true
*/
private boolean validateVendorWithholdingTaxDates(VendorDetail vdDocument) {
DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
Date beginDate = vdDocument.getVendorHeader().getVendorFederalWithholdingTaxBeginningDate();
Date endDate = vdDocument.getVendorHeader().getVendorFederalWithholdingTaxEndDate();
if (ObjectUtils.isNotNull(beginDate) && ObjectUtils.isNotNull(endDate)) {
if (dateTimeService.dateDiff(beginDate, endDate, false) <= 0) {
putFieldError(VendorPropertyConstants.VENDOR_FEDERAL_WITHHOLDING_TAX_BEGINNING_DATE, VendorKeyConstants.ERROR_VENDOR_TAX_BEGIN_DATE_AFTER_END);
return false;
}
}
return true;
}
Aggregations