List of usage examples for org.joda.time DateTime getDayOfMonth
public int getDayOfMonth()
From source file:org.kuali.kpme.core.leaveplan.service.LeavePlanServiceImpl.java
License:Educational Community License
@Override public boolean isFirstCalendarPeriodOfLeavePlan(CalendarEntry calendarEntry, String leavePlan, LocalDate asOfDate) {//www .java 2 s .c o m boolean isFirstCalendarPeriodOfLeavePlan = false; LeavePlan leavePlanObj = getLeavePlan(leavePlan, asOfDate); if (leavePlanObj != null) { DateTime calendarEntryEndDate = calendarEntry.getBeginPeriodFullDateTime(); int calendarYearStartMonth = Integer.valueOf(leavePlanObj.getCalendarYearStartMonth()); int calendarYearStartDay = Integer.valueOf(leavePlanObj.getCalendarYearStartDayOfMonth()); int calendarEntryEndDateMonth = calendarEntryEndDate.getMonthOfYear(); int calendarEntryEndDateDay = calendarEntryEndDate.getDayOfMonth(); isFirstCalendarPeriodOfLeavePlan = (calendarYearStartMonth == calendarEntryEndDateMonth) && (calendarYearStartDay == calendarEntryEndDateDay); } return isFirstCalendarPeriodOfLeavePlan; }
From source file:org.kuali.kpme.core.leaveplan.service.LeavePlanServiceImpl.java
License:Educational Community License
@Override public boolean isLastCalendarPeriodOfLeavePlan(CalendarEntry calendarEntry, String leavePlan, LocalDate asOfDate) {/*from w w w . j a v a2 s. c om*/ boolean isLastCalendarPeriodOfLeavePlan = false; LeavePlan leavePlanObj = getLeavePlan(leavePlan, asOfDate); if (leavePlanObj != null) { DateTime calendarEntryEndDate = calendarEntry.getEndPeriodFullDateTime(); int calendarYearStartMonth = Integer.valueOf(leavePlanObj.getCalendarYearStartMonth()); int calendarYearStartDay = Integer.valueOf(leavePlanObj.getCalendarYearStartDayOfMonth()); int calendarEntryEndDateMonth = calendarEntryEndDate.getMonthOfYear(); int calendarEntryEndDateDay = calendarEntryEndDate.getDayOfMonth(); isLastCalendarPeriodOfLeavePlan = (calendarYearStartMonth == calendarEntryEndDateMonth) && (calendarYearStartDay == calendarEntryEndDateDay); } return isLastCalendarPeriodOfLeavePlan; }
From source file:org.kuali.kpme.tklm.leave.accrual.service.AccrualServiceImpl.java
License:Educational Community License
@Override public DateTime getPreviousAccrualIntervalDate(String earnInterval, DateTime aDate) { DateTime previousAccrualIntervalDate = null; if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.DAILY)) { previousAccrualIntervalDate = aDate.minusDays(1); } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.WEEKLY)) { previousAccrualIntervalDate = aDate.minusWeeks(1).withDayOfWeek(DateTimeConstants.SATURDAY); } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.SEMI_MONTHLY)) { previousAccrualIntervalDate = aDate.minusDays(15); if (previousAccrualIntervalDate.getDayOfMonth() <= 15) { previousAccrualIntervalDate = previousAccrualIntervalDate.withDayOfMonth(15); } else {/*from w ww . j a va 2s . c om*/ previousAccrualIntervalDate = previousAccrualIntervalDate .withDayOfMonth(previousAccrualIntervalDate.dayOfMonth().getMaximumValue()); } } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.MONTHLY)) { previousAccrualIntervalDate = aDate.minusMonths(1); previousAccrualIntervalDate = previousAccrualIntervalDate .withDayOfMonth(previousAccrualIntervalDate.dayOfMonth().getMaximumValue()); } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.YEARLY)) { previousAccrualIntervalDate = aDate.minusYears(1); previousAccrualIntervalDate = previousAccrualIntervalDate .withDayOfYear(previousAccrualIntervalDate.dayOfYear().getMaximumValue()); } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.NO_ACCRUAL)) { previousAccrualIntervalDate = aDate; } return previousAccrualIntervalDate; }
From source file:org.kuali.kpme.tklm.leave.accrual.service.AccrualServiceImpl.java
License:Educational Community License
@Override public DateTime getNextAccrualIntervalDate(String earnInterval, DateTime aDate) { DateTime nextAccrualIntervalDate = null; if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.DAILY)) { nextAccrualIntervalDate = aDate; } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.WEEKLY)) { if (aDate.getDayOfWeek() != DateTimeConstants.SATURDAY) { nextAccrualIntervalDate = aDate.withDayOfWeek(DateTimeConstants.SATURDAY); } else {/* w w w .j av a2s . c o m*/ nextAccrualIntervalDate = aDate.withWeekOfWeekyear(1); } } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.SEMI_MONTHLY)) { if (aDate.getDayOfMonth() <= 15) { nextAccrualIntervalDate = aDate.withDayOfMonth(15); } else { nextAccrualIntervalDate = aDate.withDayOfMonth(aDate.dayOfMonth().getMaximumValue()); } } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.MONTHLY)) { nextAccrualIntervalDate = aDate.withDayOfMonth(aDate.dayOfMonth().getMaximumValue()); } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.YEARLY)) { nextAccrualIntervalDate = aDate.withDayOfYear(aDate.dayOfYear().getMaximumValue()); } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.NO_ACCRUAL)) { nextAccrualIntervalDate = aDate; } return nextAccrualIntervalDate; }
From source file:org.kuali.kpme.tklm.leave.accrual.service.AccrualServiceImpl.java
License:Educational Community License
@Override public int getWorkDaysInAccrualInterval(String earnInterval, DateTime aDate) { if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.DAILY)) { return 1; } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.WEEKLY)) { return 5; } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.SEMI_MONTHLY)) { if (aDate.getDayOfMonth() <= 15) { return TKUtils.getWorkDays(aDate.withDayOfMonth(1), aDate.withDayOfMonth(15)); } else {/* w ww .j a v a 2s . c o m*/ return TKUtils.getWorkDays(aDate.withDayOfMonth(16), aDate.withDayOfMonth(aDate.dayOfMonth().getMaximumValue())); } } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.MONTHLY)) { return TKUtils.getWorkDays(aDate.withDayOfMonth(1), aDate.withDayOfMonth(aDate.dayOfMonth().getMaximumValue())); } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.YEARLY)) { return TKUtils.getWorkDays(aDate.withDayOfYear(1), aDate.withDayOfYear(aDate.dayOfYear().getMaximumValue())); } else if (earnInterval.equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.NO_ACCRUAL)) { return 0; } return 0; }
From source file:org.kuali.kpme.tklm.leave.accrual.service.AccrualServiceImpl.java
License:Educational Community License
public DateTime getRuleStartDate(String earnInterval, LocalDate serviceDate, Long startAcc) { DateTime ruleStartDate = null; String intervalValue = HrConstants.SERVICE_UNIT_OF_TIME.get(earnInterval); if (intervalValue.equals("Months")) { ruleStartDate = serviceDate.toDateTimeAtStartOfDay().plusMonths(startAcc.intValue()); if (ruleStartDate.getDayOfMonth() > ruleStartDate.dayOfMonth().getMaximumValue()) { ruleStartDate = ruleStartDate.withDayOfMonth(ruleStartDate.dayOfMonth().getMaximumValue()); }//from w w w. jav a2s .com } else if (intervalValue.equals("Years")) { ruleStartDate = serviceDate.toDateTimeAtStartOfDay().withYear(startAcc.intValue()); } else { ruleStartDate = serviceDate.toDateTimeAtStartOfDay(); } return ruleStartDate; }
From source file:org.mayocat.shop.front.context.DateContext.java
License:Mozilla Public License
public DateContext(Date date, Locale locale) { DateTime dt = new DateTime(date); shortDate = DateTimeFormat.shortDate().withLocale(locale).print(dt); longDate = DateTimeFormat.longDate().withLocale(locale).print(dt); dayOfMonth = dt.getDayOfMonth(); monthOfYear = dt.getMonthOfYear();//from w w w .j a v a 2 s .c o m year = dt.getYear(); time = dt.toDate().getTime(); dateTime = dt.toString(); }
From source file:org.medici.bia.controller.admin.EditUserController.java
License:Open Source License
/** * /*from w ww . ja va 2 s . c o m*/ * @param command * @param result * @return */ @RequestMapping(method = RequestMethod.GET) public ModelAndView setupForm(@ModelAttribute("command") EditUserCommand command) { Map<String, Object> model = new HashMap<String, Object>(0); List<Month> months = null; User user = new User(); try { months = getAdminService().getMonths(); model.put("months", months); List<UserAuthority> authorities = getAdminService().getAuthorities(); model.put("authorities", authorities); } catch (ApplicationThrowable ath) { return new ModelAndView("error/ShowDocument", model); } try { if (StringUtils.isNotBlank(command.getAccount())) { user = getAdminService().findUser(command.getAccount()); if (user != null) { command.setAccount(user.getAccount()); command.setOriginalAccount(user.getAccount()); command.setFirstName(user.getFirstName()); command.setMiddleName(user.getMiddleName()); command.setLastName(user.getLastName()); command.setPassword(user.getPassword()); Iterator<UserRole> iterator = user.getUserRoles().iterator(); List<String> userRoles = new ArrayList<String>(0); while (iterator.hasNext()) { UserRole userRole = iterator.next(); userRoles.add(userRole.getUserAuthority().getAuthority().toString()); } command.setUserRoles(userRoles); DateTime expirationUserDate = new DateTime(user.getExpirationDate()); command.setYearExpirationUser(expirationUserDate.getYear()); command.setMonthExpirationUser(new Month(expirationUserDate.getMonthOfYear()).getMonthNum()); command.setDayExpirationUser(expirationUserDate.getDayOfMonth()); DateTime expirationPasswordDate = new DateTime(user.getExpirationPasswordDate()); command.setYearExpirationPassword(expirationPasswordDate.getYear()); command.setMonthExpirationPassword( new Month(expirationPasswordDate.getMonthOfYear()).getMonthNum()); command.setDayExpirationPassword(expirationPasswordDate.getDayOfMonth()); command.setActive(user.getActive()); command.setApproved(user.getApproved()); command.setLocked(user.getLocked()); } } else { // If account is blank, flow manage create new account command.setAccount(""); command.setFirstName(""); command.setLastName(""); command.setPassword(""); // Default user role is GUEST List<String> userRoles = new ArrayList<String>(0); userRoles.add(UserAuthority.Authority.COMMUNITY_USERS.toString()); command.setUserRoles(userRoles); Integer expirationUserMonth = NumberUtils .toInt(ApplicationPropertyManager.getApplicationProperty("user.expiration.user.months")); DateTime expirationUserDate = (new DateTime()).plusMonths(expirationUserMonth); command.setYearExpirationUser(expirationUserDate.getYear()); command.setMonthExpirationUser(new Month(expirationUserDate.getMonthOfYear()).getMonthNum()); command.setDayExpirationUser(expirationUserDate.getDayOfMonth()); Integer expirationPasswordMonth = NumberUtils.toInt( ApplicationPropertyManager.getApplicationProperty("user.expiration.password.months")); DateTime expirationPasswordDate = (new DateTime()).plusMonths(expirationPasswordMonth); command.setYearExpirationPassword(expirationPasswordDate.getYear()); command.setMonthExpirationPassword( new Month(expirationPasswordDate.getMonthOfYear()).getMonthNum()); command.setDayExpirationPassword(expirationPasswordDate.getDayOfMonth()); command.setActive(Boolean.TRUE); command.setApproved(Boolean.TRUE); command.setLocked(Boolean.FALSE); } } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); return new ModelAndView("error/EditUser", model); } return new ModelAndView("admin/EditUser", model); }
From source file:org.mifos.customers.center.struts.action.CenterCustAction.java
License:Open Source License
@TransactionDemarcate(saveToken = true) public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception { CenterCustActionForm actionForm = (CenterCustActionForm) form; actionForm.clearActionFormFields();//from ww w . j a va 2 s.c o m SessionUtils.removeAttribute(CustomerConstants.CUSTOMER_MEETING, request); UserContext userContext = getUserContext(request); CenterCreation centerCreationDto = new CenterCreation(actionForm.getOfficeIdValue(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale()); CenterFormCreationDto centerFormCreation = this.centerServiceFacade .retrieveCenterFormCreationData(centerCreationDto); // SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<Serializable>(), request); SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, centerFormCreation.getActiveLoanOfficersForBranch(), request); SessionUtils.setCollectionAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, centerFormCreation.getAdditionalFees(), request); // actionForm.setCustomFields(centerFormCreation.getCustomFieldViews()); actionForm.setDefaultFees(centerFormCreation.getDefaultFees()); DateTime today = new DateTime().toDateMidnight().toDateTime(); actionForm.setMfiJoiningDate(today.getDayOfMonth(), today.getMonthOfYear(), today.getYear()); return mapping.findForward(ActionForwards.load_success.toString()); }
From source file:org.mifos.test.acceptance.framework.loan.RedoLoanDisbursalEntryPage.java
License:Open Source License
public void enterDisbursementDate(DateTime disbursalDate) { selenium.type("disbursementDateDD", Integer.valueOf(disbursalDate.getDayOfMonth()).toString()); selenium.type("disbursementDateMM", Integer.valueOf(disbursalDate.getMonthOfYear()).toString()); selenium.type("disbursementDateYY", Integer.valueOf(disbursalDate.getYearOfEra()).toString()); selenium.fireEvent("disbursementDateYY", "blur"); }