List of usage examples for org.joda.time DateTime getMonthOfYear
public int getMonthOfYear()
From source file:org.mifos.application.servicefacade.LoanAccountServiceFacadeWebTier.java
License:Open Source License
private BigDecimal cumulativeTotalForMonth(DateTime dateOfCashFlow, LoanScheduleDto loanScheduleDto) { BigDecimal value = new BigDecimal(0).setScale(2, BigDecimal.ROUND_HALF_UP); for (LoanCreationInstallmentDto repaymentScheduleInstallment : loanScheduleDto.getInstallments()) { DateTime dueDate = new DateTime(repaymentScheduleInstallment.getDueDate()); if (dueDate.getMonthOfYear() == dateOfCashFlow.getMonthOfYear() && (dueDate.getYear() == dateOfCashFlow.getYear())) { value = value.add(BigDecimal.valueOf(repaymentScheduleInstallment.getTotal())); }/* w ww. j av a 2 s .c o m*/ } return value; }
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 w ww . j ava2 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.platform.cashflow.service.CashFlowServiceImpl.java
License:Open Source License
@Override public CashFlowBoundary getCashFlowBoundary(DateTime firstInstallmentDueDate, DateTime lastInstallmentDueDate) { DateTime monthAfterLastInstallment = lastInstallmentDueDate .plusMonths(EXTRA_DURATION_FOR_CASH_FLOW_SCHEDULE).withDayOfMonth(FIRST_DAY); DateTime monthBeforeFirstInstallment = firstInstallmentDueDate .minusMonths(EXTRA_DURATION_FOR_CASH_FLOW_SCHEDULE).withDayOfMonth(FIRST_DAY); int numberOfMonths = Months.monthsBetween(monthBeforeFirstInstallment, monthAfterLastInstallment) .getMonths() + 1;/*from w w w . ja v a2s. c o m*/ return new CashFlowBoundary(monthBeforeFirstInstallment.getMonthOfYear(), monthBeforeFirstInstallment.getYear(), numberOfMonths); }
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"); }
From source file:org.mifos.test.acceptance.framework.testhelpers.SavingsProductHelper.java
License:Open Source License
/** * This method return a fully useable parameter object for the type of deposit (mandatory/voluntary) * and applicable for (clients/groups/centers). * @return Parameters like noted above./* w w w . j ava 2 s. co m*/ * @param typeOfDeposits * @param applicableFor */ public SavingsProductParameters getGenericSavingsProductParameters(DateTime startDate, int typeOfDeposits, int applicableFor) { SavingsProductParameters params = new SavingsProductParameters(); params.setProductInstanceName("Savings product test" + StringUtil.getRandomString(3)); params.setShortName(StringUtil.getRandomString(4)); params.setProductCategory(SavingsProductParameters.OTHER); params.setStartDateDD(Integer.valueOf(startDate.getDayOfMonth()).toString()); params.setStartDateMM(Integer.valueOf(startDate.getMonthOfYear()).toString()); params.setStartDateYYYY(Integer.valueOf(startDate.getYearOfEra()).toString()); params.setApplicableFor(applicableFor); params.setTypeOfDeposits(typeOfDeposits); // these two settings are not required in all configurations // but they're good to have anyway params.setMandatoryAmount("10"); params.setAmountAppliesTo(SavingsProductParameters.WHOLE_GROUP); params.setInterestRate("4"); params.setBalanceUsedForInterestCalculation(SavingsProductParameters.AVERAGE_BALANCE); params.setDaysOrMonthsForInterestCalculation(SavingsProductParameters.MONTHS); params.setNumberOfDaysOrMonthsForInterestCalculation("3"); params.setFrequencyOfInterestPostings("6"); params.setGlCodeForDeposit("24101 - Mandatory Savings Accounts"); params.setGlCodeForInterest("41102 - Interest on clients mandatory savings"); return params; }
From source file:org.mifos.ui.core.controller.GeneralProductBeanAssembler.java
License:Open Source License
private void defaultStartDateToToday(GeneralProductBean formBean) { DateTime today = new DateTime(); formBean.setStartDateDay(today.getDayOfMonth()); formBean.setStartDateMonth(today.getMonthOfYear()); formBean.setStartDateYear(Integer.valueOf(today.getYearOfEra()).toString()); }
From source file:org.mifos.ui.core.controller.SystemUserController.java
License:Open Source License
public UserFormBean createUserFormBean(final Long officeId, final UserFormBean formBean) { OfficeDto selectedOffice = this.officeServiceFacade.retrieveOfficeById(officeId.shortValue()); formBean.setOfficeId(officeId);/*from www.j av a 2 s . c o m*/ formBean.setOfficeName(selectedOffice.getName()); MandatoryHiddenFieldsDto dtoFields = this.adminServiceFacade.retrieveHiddenMandatoryFields(); formBean.getAddress().setAddress1Mandatory(dtoFields.isMandatorySystemAddress1()); formBean.getAddress().setAddress2Hidden(dtoFields.isHideSystemAddress2()); formBean.getAddress().setAddress3Hidden(dtoFields.isHideSystemAddress3()); formBean.getAddress().setCityDistrictHidden(dtoFields.isHideSystemCity()); formBean.getAddress().setStateHidden(dtoFields.isHideSystemState()); formBean.getAddress().setCountryHidden(dtoFields.isHideSystemCountry()); formBean.getAddress().setPostalCodeHidden(dtoFields.isHideSystemPostalCode()); DefinePersonnelDto userRefData = this.personnelServiceFacade .retrieveInfoForNewUserDefinition(officeId.shortValue()); Map<String, String> genderOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getGenderList()) { genderOptions.put(option.getId().toString(), option.getName()); } formBean.setGenderOptions(genderOptions); Map<String, String> maritalStatusOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getMaritalStatusList()) { maritalStatusOptions.put(option.getId().toString(), option.getName()); } formBean.setMaritalStatusOptions(maritalStatusOptions); Map<String, String> preferredLanguageOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getLanguageList()) { preferredLanguageOptions.put(option.getId().toString(), option.getName()); } formBean.setPreferredLanguageOptions(preferredLanguageOptions); Map<String, String> userTitleOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getTitleList()) { userTitleOptions.put(option.getId().toString(), option.getName()); } formBean.setUserTitleOptions(userTitleOptions); Map<String, String> userHierarchyOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getPersonnelLevelList()) { userHierarchyOptions.put(option.getId().toString(), option.getName()); } formBean.setUserHierarchyOptions(userHierarchyOptions); Map<String, String> availableRolesOptions = new LinkedHashMap<String, String>(); for (ListElement option : userRefData.getRolesList()) { availableRolesOptions.put(option.getId().toString(), option.getName()); } formBean.setAvailableRolesOptions(availableRolesOptions); formBean.setSelectedRolesOptions(new LinkedHashMap<String, String>()); DateTime today = new DateTime(); formBean.setMfiJoiningDateDay(today.getDayOfMonth()); formBean.setMfiJoiningDateMonth(today.getMonthOfYear()); formBean.setMfiJoiningDateYear(today.getYearOfEra()); return formBean; }
From source file:org.mitre.xtemporal.DateNormalization.java
License:Apache License
/** * * @param elements//from w w w . j a v a 2 s . c om * @return * @throws java.text.ParseException */ public static int normalize_month_name(java.util.Map<String, String> elements) throws java.text.ParseException { // MM, MONTH -- numeric 01-12 // MON_ABBREV, MON_NAME -- text // String ABBREV = elements.get("MON_ABBREV"); String NAME = elements.get("MON_NAME"); String text = null; if (ABBREV != null) { text = ABBREV; } else if (NAME != null) { text = NAME; } else { return INVALID_DATE; } if (text.length() < 3) { return INVALID_DATE; } // Standardize on month trigraph, e.g. ,DEC can get DECEMBER or DECIEMBRE // DateTime mon = fmt_month.parseDateTime(text.substring(0, 3)); return mon.getMonthOfYear(); }
From source file:org.mongoste.util.DateUtil.java
License:Open Source License
public static DateTime toUTC(DateTime fromDate) { if (DateTimeZone.UTC.equals(fromDate.getZone())) { return fromDate; }//from w w w .j ava2 s.c om MutableDateTime dt = getDateTimeUTC().toMutableDateTime(); dt.setDateTime(fromDate.getYear(), fromDate.getMonthOfYear(), fromDate.getDayOfMonth(), fromDate.getHourOfDay(), fromDate.getMinuteOfHour(), fromDate.getSecondOfMinute(), fromDate.getMillisOfSecond()); return dt.toDateTime(); }
From source file:org.mrgeo.featurefilter.DateColumnFeatureFilter.java
License:Apache License
private boolean datePassesFilter(DateTime date, DateTime filter) { return ((dateFilterGranularity.equals(DateGranularity.AFTER) && date.isAfter(filter)) || (dateFilterGranularity.equals(DateGranularity.BEFORE) && date.isBefore(filter)) || (dateFilterGranularity.equals(DateGranularity.SAME_INSTANT) && filter.isEqual(date)) || (dateFilterGranularity.equals(DateGranularity.WITHIN_A_MINUTE) && (Minutes.minutesBetween(filter, date).getMinutes() == 0)) || (dateFilterGranularity.equals(DateGranularity.WITHIN_AN_HOUR) && (Hours.hoursBetween(filter, date).getHours() == 0)) || (dateFilterGranularity.equals(DateGranularity.WITHIN_A_DAY) && (Days.daysBetween(filter, date).getDays() == 0)) || (dateFilterGranularity.equals(DateGranularity.WITHIN_A_MONTH) && (Months.monthsBetween(filter, date).getMonths() == 0)) || (dateFilterGranularity.equals(DateGranularity.WITHIN_A_YEAR) && (Years.yearsBetween(filter, date).getYears() == 0)) || (dateFilterGranularity.equals(DateGranularity.SAME_MINUTE_OF_ANY_HOUR) && (date.getMinuteOfHour() == filter.getMinuteOfHour())) || (dateFilterGranularity.equals(DateGranularity.SAME_HOUR_OF_ANY_DAY) && (date.getHourOfDay() == filter.getHourOfDay())) || (dateFilterGranularity.equals(DateGranularity.SAME_DAY_OF_ANY_WEEK) && (date.getDayOfWeek() == filter.getDayOfWeek())) || (dateFilterGranularity.equals(DateGranularity.SAME_DAY_OF_ANY_MONTH) && (date.getDayOfMonth() == filter.getDayOfMonth())) ||//from w ww .jav a 2 s . co m //date.getDayOfYear isn't sufficient here, b/c leap years have a different number of days (dateFilterGranularity.equals(DateGranularity.SAME_DAY_OF_ANY_YEAR) && ((date.getDayOfMonth() == filter.getDayOfMonth()) && (date.getMonthOfYear() == filter.getMonthOfYear()))) || (dateFilterGranularity.equals(DateGranularity.SAME_MONTH_OF_ANY_YEAR) && (date.getMonthOfYear() == filter.getMonthOfYear()))); }