List of usage examples for org.joda.time LocalDate dayOfWeek
public Property dayOfWeek()
From source file:op.care.reports.PnlReport.java
License:Open Source License
private CollapsiblePane createCP4Week(final LocalDate week) { final String key = weekFormater.format(week.toDate()) + ".week"; synchronized (cpMap) { if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try { cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. }// w w w .j av a2s . co m } } final CollapsiblePane cpWeek = cpMap.get(key); String title = "<html><font size=+1><b>" + DateFormat.getDateInstance(DateFormat.SHORT).format(week.dayOfWeek().withMaximumValue().toDate()) + " - " + DateFormat.getDateInstance(DateFormat.SHORT).format(week.dayOfWeek().withMinimumValue().toDate()) + " (" + SYSTools.xx("misc.msg.weekinyear") + week.getWeekOfWeekyear() + ")" + "</b>" + "</font></html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cpWeek.setCollapsed(!cpWeek.isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); GUITools.addExpandCollapseButtons(cpWeek, cptitle.getRight()); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) { final JButton btnPrintWeek = new JButton(SYSConst.icon22print2); btnPrintWeek.setPressedIcon(SYSConst.icon22print2Pressed); btnPrintWeek.setAlignmentX(Component.RIGHT_ALIGNMENT); btnPrintWeek.setContentAreaFilled(false); btnPrintWeek.setBorder(null); btnPrintWeek.setToolTipText(SYSTools.xx("misc.tooltips.btnprintweek")); btnPrintWeek.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { SYSFilesTools.print(NReportTools.getNReportsAsHTML( NReportTools.getNReports4Week(resident, week), true, null, null), false); } }); cptitle.getRight().add(btnPrintWeek); } cpWeek.setTitleLabelComponent(cptitle.getMain()); cpWeek.setSlidingDirection(SwingConstants.SOUTH); cpWeek.setBackground(SYSConst.orange1[SYSConst.medium1]); cpWeek.setOpaque(false); cpWeek.setHorizontalAlignment(SwingConstants.LEADING); // cpMonth.setBackground(getColor(vtype, SYSConst.light3)); /*** * _ _ _ _ _ _ * ___| (_) ___| | _____ __| | ___ _ __ _ __ ___ ___ _ __ | |_| |__ * / __| | |/ __| |/ / _ \/ _` | / _ \| '_ \ | '_ ` _ \ / _ \| '_ \| __| '_ \ * | (__| | | (__| < __/ (_| | | (_) | | | | | | | | | | (_) | | | | |_| | | | * \___|_|_|\___|_|\_\___|\__,_| \___/|_| |_| |_| |_| |_|\___/|_| |_|\__|_| |_| * */ cpWeek.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { cpWeek.setContentPane(createContenPanel4Week(week)); } }); if (!cpWeek.isCollapsed()) { cpWeek.setContentPane(createContenPanel4Week(week)); } return cpWeek; }
From source file:op.care.reports.PnlReport.java
License:Open Source License
private JPanel createContenPanel4Week(LocalDate week) { JPanel pnlWeek = new JPanel(new VerticalLayout()); pnlWeek.setOpaque(false);//from w ww. j av a2 s .co m LocalDate now = new LocalDate(); boolean sameWeek = now.dayOfWeek().withMaximumValue().equals(week.dayOfWeek().withMaximumValue()); final LocalDate start = sameWeek ? now : SYSCalendar.eow(week); final LocalDate end = SYSCalendar.bow(week); for (LocalDate day = start; end.compareTo(day) <= 0; day = day.minusDays(1)) { pnlWeek.add(createCP4Day(day)); } return pnlWeek; }
From source file:op.tools.SYSCalendar.java
License:Open Source License
public static LocalDate bow(LocalDate d) { return d.dayOfWeek().withMinimumValue(); }
From source file:op.tools.SYSCalendar.java
License:Open Source License
public static LocalDate eow(LocalDate d) { return d.dayOfWeek().withMaximumValue(); }
From source file:org.egov.lcms.transactions.service.LegalCommonReportService.java
License:Open Source License
private BoolQueryBuilder getFilterQuery(final LegalCommonReportResult searchRequest, final String reportType) throws ParseException { final SimpleDateFormat formatter = new SimpleDateFormat(LcmsConstants.DATE_FORMAT); final SimpleDateFormat newFormat = new SimpleDateFormat(ApplicationConstant.ES_DATE_FORMAT); final Map<String, Integer> monthValuesMapnumber = LegalCaseUtil.getAllMonthsInNumber(); BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); boolQuery.filter(QueryBuilders.termQuery("cityName", ApplicationThreadLocals.getCityName())); if (StringUtils.isNotBlank(searchRequest.getAggregatedByValue())) { if (searchRequest.getAggregatedBy().equals(LcmsConstants.COURTNAME)) boolQuery.filter(QueryBuilders.matchQuery(COURTNAME, searchRequest.getAggregatedByValue())); if (searchRequest.getAggregatedBy().equals(LcmsConstants.PETITIONTYPE)) boolQuery.filter(QueryBuilders.matchQuery(PETITIONTYPE, searchRequest.getAggregatedByValue())); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.CASECATEGORY)) boolQuery.filter(QueryBuilders.matchQuery(CASETYPE, searchRequest.getAggregatedByValue())); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.CASESTATUS)) boolQuery.filter(QueryBuilders.matchQuery(CASESTATUS, searchRequest.getAggregatedByValue())); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.COURTTYPE)) boolQuery.filter(QueryBuilders.matchQuery(COURTTYPE, searchRequest.getAggregatedByValue())); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.OFFICERINCHRGE)) boolQuery.filter(QueryBuilders.matchQuery(OFFICERINCHRGE, searchRequest.getAggregatedByValue().split("@")[0])); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.STANDINGCOUNSEL)) boolQuery.filter(QueryBuilders.matchQuery(STANDINGCOUNSEL, searchRequest.getAggregatedByValue())); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.JUDGEMENTOUTCOME)) boolQuery.filter(QueryBuilders.matchQuery(JUDGEMENTOUTCOME, searchRequest.getAggregatedByValue())); }/* w w w . j a v a 2s . c o m*/ if (StringUtils.isNotBlank(searchRequest.getMonth()) && StringUtils.isNotBlank(searchRequest.getYear())) { final Integer monthName = monthValuesMapnumber.get(searchRequest.getMonth()); // Prepare the start date based on the month number and year final String monthYearStartDateStr = searchRequest.getYear().concat("-").concat(monthName.toString()) .concat("-").concat("01"); final LocalDate monthYearStDate = new LocalDate(monthYearStartDateStr); // Fetch the start date of the 1st week of the month and the last day of the month if (MONTH.equalsIgnoreCase(searchRequest.getPeriod())) { final LocalDate weekStart = monthYearStDate.dayOfWeek().withMinimumValue(); final LocalDate endOfMonth = monthYearStDate.dayOfMonth().withMaximumValue(); final String startDate = weekStart.toString(LcmsConstants.DATE_FORMAT); final String endDate = endOfMonth.toString(LcmsConstants.DATE_FORMAT); boolQuery = boolQuery.filter( QueryBuilders.rangeQuery(CASE_DATE).gte(newFormat.format(formatter.parse(startDate))) .lte(new DateTime(newFormat.format(formatter.parse(endDate))))); } if (YEAR.equalsIgnoreCase(searchRequest.getPeriod())) { final LocalDate monthStart = monthYearStDate.dayOfMonth().withMinimumValue(); final LocalDate endOfYear = monthYearStDate.dayOfYear().withMaximumValue(); final String startDate = monthStart.toString(LcmsConstants.DATE_FORMAT); final String endDate = endOfYear.toString(LcmsConstants.DATE_FORMAT); boolQuery = boolQuery.filter( QueryBuilders.rangeQuery(CASE_DATE).gte(newFormat.format(formatter.parse(startDate))) .lte(new DateTime(newFormat.format(formatter.parse(endDate))))); } } if (reportType != null) { if (reportType.equals(LcmsConstants.DUEPWRREPORT)) boolQuery.mustNot(QueryBuilders.existsQuery("pwrDueDate")); else if (reportType.equals(LcmsConstants.DUECAREPORT)) boolQuery.must(QueryBuilders.existsQuery("caDueDate")); else if (reportType.equals(LcmsConstants.DUEJUDGEMENTIMPLPREPORT)) boolQuery.mustNot(QueryBuilders.matchQuery("status", LcmsConstants.LEGALCASE_STATUS_CLOSED_DESC)); if (reportType.equals(LcmsConstants.DUEJUDGEMENTIMPLPREPORT) && StringUtils.isNotBlank(searchRequest.getCaseFromDate())) boolQuery = boolQuery.filter(QueryBuilders.rangeQuery("judgmentImplDate") .gte(newFormat.format(formatter.parse(searchRequest.getCaseFromDate()))) .lte(new DateTime(newFormat.format(formatter.parse(searchRequest.getCaseToDate()))))); if (reportType.equals(LcmsConstants.DUEEMPLOYEEHEARINGREPORT)) { final List<String> statusCodeList = new ArrayList<>(); statusCodeList.add(LcmsConstants.LEGALCASE_STATUS_HEARING_DESC); statusCodeList.add(LcmsConstants.LEGALCASE_INTERIMSTAY_STATUS_DESC); boolQuery.must(QueryBuilders.termsQuery(CASESTATUS, statusCodeList)); if (searchRequest.getLcNumber() != null) boolQuery = boolQuery.filter(QueryBuilders.matchQuery("lcNumber", searchRequest.getLcNumber())); if (StringUtils.isNotBlank(searchRequest.getCaseFromDate())) boolQuery = boolQuery.filter(QueryBuilders.rangeQuery(CASE_DATE) .gte(newFormat.format(formatter.parse(searchRequest.getCaseFromDate()))) .lte(new DateTime(newFormat.format(formatter.parse(searchRequest.getCaseToDate()))))); } } else if (StringUtils.isNotBlank(searchRequest.getCaseFromDate())) boolQuery = boolQuery.filter(QueryBuilders.rangeQuery(CASE_DATE) .gte(newFormat.format(formatter.parse(searchRequest.getCaseFromDate()))) .lte(new DateTime(newFormat.format(formatter.parse(searchRequest.getCaseToDate()))))); if (StringUtils.isNotBlank(searchRequest.getOfficerIncharge())) boolQuery = boolQuery.filter( QueryBuilders.termQuery(OFFICERINCHRGE, searchRequest.getOfficerIncharge().split("@")[0])); if (StringUtils.isNotBlank(searchRequest.getCaseCategory())) boolQuery = boolQuery.filter(QueryBuilders.termQuery(CASETYPE, searchRequest.getCaseCategory())); if (StringUtils.isNotBlank(searchRequest.getCourtName())) boolQuery = boolQuery.filter(QueryBuilders.termQuery(COURTNAME, searchRequest.getCourtName())); if (StringUtils.isNotBlank(searchRequest.getCaseStatus())) boolQuery = boolQuery.filter(QueryBuilders.termQuery(CASESTATUS, searchRequest.getCaseStatus())); if (StringUtils.isNotBlank(searchRequest.getCourtType())) boolQuery = boolQuery.filter(QueryBuilders.termQuery(COURTTYPE, searchRequest.getCourtType())); if (StringUtils.isNotBlank(searchRequest.getPetitionType())) boolQuery = boolQuery.filter(QueryBuilders.termQuery(PETITIONTYPE, searchRequest.getPetitionType())); if (StringUtils.isNotBlank(searchRequest.getJudgmentType())) boolQuery = boolQuery .filter(QueryBuilders.termQuery(JUDGEMENTOUTCOME, searchRequest.getJudgmentType())); if (StringUtils.isNotBlank(searchRequest.getStandingCounsel())) boolQuery = boolQuery .filter(QueryBuilders.termQuery("advocateName", searchRequest.getStandingCounsel())); if (StringUtils.isNotBlank(searchRequest.getReportStatus())) boolQuery = boolQuery.filter(QueryBuilders.termQuery("subStatus", searchRequest.getReportStatus())); return boolQuery; }
From source file:org.egov.ptis.web.controller.dashboard.CMDashboardController.java
License:Open Source License
/** * Provides citywise DCB details across all ULBs for MIS Reports * @return response JSON//w ww . j av a2 s . c om * @throws IOException */ @RequestMapping(value = "/citywisedcb", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public MISDCBDetails getDCBDetailsForMIS(CollectionDetailsRequest collectionDetailsRequest) { MISDCBDetails misDCBDetails = new MISDCBDetails(); List<WeeklyDCB> weekwiseDCBDetails; List<MonthlyDCB> monthwiseDCBDetails; if (StringUtils.isBlank(collectionDetailsRequest.getIntervalType())) misDCBDetails.setDcbDetails(propTaxDashboardService.getDCBDetails(collectionDetailsRequest)); else { String startDate; String endDate; if (WEEK.equalsIgnoreCase(collectionDetailsRequest.getIntervalType())) { String monthStartDateStr = collectionDetailsRequest.getYear().concat("-") .concat(collectionDetailsRequest.getMonth()).concat("-").concat("01"); LocalDate monthStDate = new LocalDate(monthStartDateStr); // Fetch the start date of the 1st week of the month and the last day of the month LocalDate weekStart = monthStDate.dayOfWeek().withMinimumValue(); LocalDate endOfMonth = monthStDate.dayOfMonth().withMaximumValue(); startDate = weekStart.toString(PropertyTaxConstants.DATE_FORMAT_YYYYMMDD); endDate = endOfMonth.toString(PropertyTaxConstants.DATE_FORMAT_YYYYMMDD); collectionDetailsRequest.setFromDate(startDate); collectionDetailsRequest.setToDate(endDate); } } if (WEEK.equalsIgnoreCase(collectionDetailsRequest.getIntervalType())) { weekwiseDCBDetails = propTaxDashboardService.getWeekwiseDCBDetails(collectionDetailsRequest, collectionDetailsRequest.getIntervalType()); misDCBDetails.setWeeklyDCBDetails(weekwiseDCBDetails); } else if (MONTH.equalsIgnoreCase(collectionDetailsRequest.getIntervalType())) { monthwiseDCBDetails = propTaxDashboardService.getMonthwiseDCBDetails(collectionDetailsRequest, collectionDetailsRequest.getIntervalType()); misDCBDetails.setMonthlyDCBDetails(monthwiseDCBDetails); } return misDCBDetails; }
From source file:org.egov.ptis.web.controller.dashboard.CMDashboardController.java
License:Open Source License
/** * Provides collection analysis data across all ULBs for MIS Reports * @return response JSON// w w w.java 2s.c o m * @throws IOException */ @RequestMapping(value = "/collectionanalysis", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public CollectionAnalysis getCollectionAnalysisForMIS(CollectionDetailsRequest collectionDetailsRequest) { if (StringUtils.isNotBlank(collectionDetailsRequest.getIntervalType())) { String startDate = StringUtils.EMPTY; String endDate = StringUtils.EMPTY; if (WEEK.equalsIgnoreCase(collectionDetailsRequest.getIntervalType())) { // Prepare the start date based on the month number and year String monthStartDateStr = collectionDetailsRequest.getYear().concat("-") .concat(collectionDetailsRequest.getMonth()).concat("-").concat("01"); LocalDate monthStDate = new LocalDate(monthStartDateStr); // Fetch the start date of the 1st week of the month and the last day of the month LocalDate weekStart = monthStDate.dayOfWeek().withMinimumValue(); LocalDate endOfMonth = monthStDate.dayOfMonth().withMaximumValue(); startDate = weekStart.toString(PropertyTaxConstants.DATE_FORMAT_YYYYMMDD); endDate = endOfMonth.toString(PropertyTaxConstants.DATE_FORMAT_YYYYMMDD); } else if (DAY.equalsIgnoreCase(collectionDetailsRequest.getIntervalType())) { // Prepare the first and last days of the week based on the month, year and week of month values DateTime date = new DateTime().withYear(Integer.parseInt(collectionDetailsRequest.getYear())) .withMonthOfYear(Integer.parseInt(collectionDetailsRequest.getMonth())); Calendar cal = date.toCalendar(Locale.getDefault()); cal.set(Calendar.DAY_OF_WEEK, 2); cal.set(Calendar.WEEK_OF_MONTH, Integer.parseInt(collectionDetailsRequest.getWeek())); DateTime weekStartDate = new DateTime(cal).withMillisOfDay(0); startDate = weekStartDate.toString(PropertyTaxConstants.DATE_FORMAT_YYYYMMDD); Date weekEndDate = DateUtils.addDays(weekStartDate.toDate(), 6); endDate = PropertyTaxConstants.DATEFORMATTER_YYYY_MM_DD.format(weekEndDate); } if (WEEK.equalsIgnoreCase(collectionDetailsRequest.getIntervalType()) || DAY.equalsIgnoreCase(collectionDetailsRequest.getIntervalType())) { collectionDetailsRequest.setFromDate(startDate); collectionDetailsRequest.setToDate(endDate); } } return propTaxDashboardService.getCollectionAnalysisData(collectionDetailsRequest, collectionDetailsRequest.getIntervalType()); }
From source file:org.freewheelschedule.freewheel.common.model.TimedTrigger.java
License:Apache License
private void setNextRunDay() { LocalDate nextCandidate = new LocalDate(); LocalDate nextRunDay = null;/* ww w .j av a 2 s . c o m*/ while (nextRunDay == null) { nextCandidate = nextCandidate.plusDays(1); if (DayOfWeek.valueOf(nextCandidate.dayOfWeek().getAsText().toUpperCase()).matches(daysOfWeek)) { nextRunDay = nextCandidate; } } runDate = nextRunDay; }
From source file:org.gnucash.android.model.Recurrence.java
License:Apache License
/** * Return the number of days left in this period * @return Number of days left in period *//* ww w.j a v a 2 s .c o m*/ public int getDaysLeftInCurrentPeriod() { LocalDate startDate = new LocalDate(System.currentTimeMillis()); int interval = mPeriodType.getMultiplier() - 1; LocalDate endDate = null; switch (mPeriodType) { case DAY: endDate = new LocalDate(System.currentTimeMillis()).plusDays(interval); break; case WEEK: endDate = startDate.dayOfWeek().withMaximumValue().plusWeeks(interval); break; case MONTH: endDate = startDate.dayOfMonth().withMaximumValue().plusMonths(interval); break; case YEAR: endDate = startDate.dayOfYear().withMaximumValue().plusYears(interval); break; } return Days.daysBetween(startDate, endDate).getDays(); }
From source file:org.gnucash.android.model.Recurrence.java
License:Apache License
/** * Returns the number of periods from the start date of this recurrence until the end of the * interval multiplier specified in the {@link PeriodType} * //fixme: Improve the documentation//from www . ja v a 2 s. c o m * @return Number of periods in this recurrence */ public int getNumberOfPeriods(int numberOfPeriods) { LocalDate startDate = new LocalDate(mPeriodStart.getTime()); LocalDate endDate; int interval = mPeriodType.getMultiplier(); //// TODO: 15.08.2016 Why do we add the number of periods. maybe rename method or param switch (mPeriodType) { case DAY: return 1; case WEEK: endDate = startDate.dayOfWeek().withMaximumValue().plusWeeks(numberOfPeriods); return Weeks.weeksBetween(startDate, endDate).getWeeks() / interval; case MONTH: endDate = startDate.dayOfMonth().withMaximumValue().plusMonths(numberOfPeriods); return Months.monthsBetween(startDate, endDate).getMonths() / interval; case YEAR: endDate = startDate.dayOfYear().withMaximumValue().plusYears(numberOfPeriods); return Years.yearsBetween(startDate, endDate).getYears() / interval; } return 0; }