List of usage examples for java.util Calendar getActualMaximum
public int getActualMaximum(int field)
Calendar
. From source file:egovframework.oe1.cms.com.web.EgovOe1CalRestdeManageController.java
/** * ? //ww w . j a v a 2 s . c o m * @param restde * @param model * @return "/cmm/sym/cal/EgovNormalYearCalendar" * @throws Exception */ @RequestMapping(value = "/com/EgovNormalYearCalendar.do") public String selectNormalYearCalendar(EgovOe1Restde restde, ModelMap model) throws Exception { Calendar cal = Calendar.getInstance(); if (restde.getYear() == null || restde.getYear().equals("")) { restde.setYear(Integer.toString(cal.get(Calendar.YEAR))); } if (restde.getMonth() == null || restde.getMonth().equals("")) { restde.setMonth(Integer.toString(cal.get(Calendar.MONTH) + 1)); } int iYear = Integer.parseInt(restde.getYear()); int iMonth = Integer.parseInt(restde.getMonth()); if (iMonth < 1) { iYear--; iMonth = 12; } if (iMonth > 12) { iYear++; iMonth = 1; } if (iYear < 1) { iYear = 1; iMonth = 1; } if (iYear > 9999) { iYear = 9999; iMonth = 12; } restde.setYear(Integer.toString(iYear)); /* ? */ /* 1 */ iMonth = 1; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_1 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_1 = restdeManageService.selectNormalMonthRestde(restde); /* 2 */ iMonth = 2; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_2 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_2 = restdeManageService.selectNormalMonthRestde(restde); /* 3 */ iMonth = 3; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_3 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_3 = restdeManageService.selectNormalMonthRestde(restde); /* 4 */ iMonth = 4; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_4 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_4 = restdeManageService.selectNormalMonthRestde(restde); /* 5 */ iMonth = 5; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_5 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_5 = restdeManageService.selectNormalMonthRestde(restde); /* 6 */ iMonth = 6; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_6 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_6 = restdeManageService.selectNormalMonthRestde(restde); /* 7 */ iMonth = 7; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_7 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_7 = restdeManageService.selectNormalMonthRestde(restde); /* 8 */ iMonth = 8; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_8 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_8 = restdeManageService.selectNormalMonthRestde(restde); /* 9 */ iMonth = 9; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_9 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_9 = restdeManageService.selectNormalMonthRestde(restde); /* 10 */ iMonth = 10; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_10 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_10 = restdeManageService.selectNormalMonthRestde(restde); /* 11 */ iMonth = 11; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_11 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_11 = restdeManageService.selectNormalMonthRestde(restde); /* 12 */ iMonth = 12; restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, 1); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList_12 = restdeManageService.selectNormalRestdePopup(restde); List NormalMonthRestdeList_12 = restdeManageService.selectNormalMonthRestde(restde); model.addAttribute("resultList_1", CalInfoList_1); model.addAttribute("resultList_2", CalInfoList_2); model.addAttribute("resultList_3", CalInfoList_3); model.addAttribute("resultList_4", CalInfoList_4); model.addAttribute("resultList_5", CalInfoList_5); model.addAttribute("resultList_6", CalInfoList_6); model.addAttribute("resultList_7", CalInfoList_7); model.addAttribute("resultList_8", CalInfoList_8); model.addAttribute("resultList_9", CalInfoList_9); model.addAttribute("resultList_10", CalInfoList_10); model.addAttribute("resultList_11", CalInfoList_11); model.addAttribute("resultList_12", CalInfoList_12); model.addAttribute("RestdeList_1", NormalMonthRestdeList_1); model.addAttribute("RestdeList_2", NormalMonthRestdeList_2); model.addAttribute("RestdeList_3", NormalMonthRestdeList_3); model.addAttribute("RestdeList_4", NormalMonthRestdeList_4); model.addAttribute("RestdeList_5", NormalMonthRestdeList_5); model.addAttribute("RestdeList_6", NormalMonthRestdeList_6); model.addAttribute("RestdeList_7", NormalMonthRestdeList_7); model.addAttribute("RestdeList_8", NormalMonthRestdeList_8); model.addAttribute("RestdeList_9", NormalMonthRestdeList_9); model.addAttribute("RestdeList_10", NormalMonthRestdeList_10); model.addAttribute("RestdeList_11", NormalMonthRestdeList_11); model.addAttribute("RestdeList_12", NormalMonthRestdeList_12); return "/cms/com/EgovNormalYearCalendar"; }
From source file:com.proyecto.vista.MantenimientoInventario.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: // Periodo periodo = (Periodo) cmbPeriodo.getSelectedItem(); Date inicio = jdateInicio.getDate(); Date fin = jDateFin.getDate(); Calendar cal = Calendar.getInstance(); if (inicio == null) { cal.set(cal.get(Calendar.YEAR), cal.getActualMinimum(Calendar.MONTH), cal.getActualMinimum(Calendar.DAY_OF_MONTH)); Date ini = cal.getTime(); jdateInicio.setDate(ini);/*from w w w . j a v a2 s. com*/ } if (fin == null) { cal.set(cal.get(Calendar.YEAR), cal.getActualMaximum(Calendar.MONTH), cal.getActualMaximum(Calendar.DAY_OF_MONTH)); Date finals = cal.getTime(); jDateFin.setDate(finals); } // System.out.println("DATE 1: "+ jdateInicio.getDate()); // System.out.println("DATE 2: "+ jDateFin.getDate()); paginaActual = 1; buscar(); actualizarControlesNavegacion(); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.PHS398FellowshipSupplementalV1_1Generator.java
private ScaleTwoDecimal getNumberOfMonths(Date dateStart, Date dateEnd) { BigDecimal monthCount = ScaleTwoDecimal.ZERO.bigDecimalValue(); int fullMonthCount = 0; Calendar startDate = Calendar.getInstance(); Calendar endDate = Calendar.getInstance(); startDate.setTime(dateStart);/*from ww w . j av a 2 s. c o m*/ endDate.setTime(dateEnd); startDate.clear(Calendar.HOUR); startDate.clear(Calendar.MINUTE); startDate.clear(Calendar.SECOND); startDate.clear(Calendar.MILLISECOND); endDate.clear(Calendar.HOUR); endDate.clear(Calendar.MINUTE); endDate.clear(Calendar.SECOND); endDate.clear(Calendar.MILLISECOND); if (startDate.after(endDate)) { return ScaleTwoDecimal.ZERO; } int startMonthDays = startDate.getActualMaximum(Calendar.DATE) - startDate.get(Calendar.DATE); startMonthDays++; int startMonthMaxDays = startDate.getActualMaximum(Calendar.DATE); BigDecimal startMonthFraction = new ScaleTwoDecimal(startMonthDays).bigDecimalValue() .divide(new ScaleTwoDecimal(startMonthMaxDays).bigDecimalValue(), RoundingMode.HALF_UP); int endMonthDays = endDate.get(Calendar.DATE); int endMonthMaxDays = endDate.getActualMaximum(Calendar.DATE); BigDecimal endMonthFraction = new ScaleTwoDecimal(endMonthDays).bigDecimalValue() .divide(new ScaleTwoDecimal(endMonthMaxDays).bigDecimalValue(), RoundingMode.HALF_UP); startDate.set(Calendar.DATE, 1); endDate.set(Calendar.DATE, 1); while (startDate.getTimeInMillis() < endDate.getTimeInMillis()) { startDate.set(Calendar.MONTH, startDate.get(Calendar.MONTH) + 1); fullMonthCount++; } fullMonthCount = fullMonthCount - 1; monthCount = monthCount.add(new ScaleTwoDecimal(fullMonthCount).bigDecimalValue()).add(startMonthFraction) .add(endMonthFraction); return new ScaleTwoDecimal(monthCount); }
From source file:org.opencms.search.CmsSearchIndex.java
/** * Generates a list of date terms for the optimized date range search with "daily" granularity level.<p> * /* www .j a v a 2s . c om*/ * How this works:<ul> * <li>For each document, terms are added for the year, the month and the day the document * was modified or created) in. So for example if a document is modified at February 02, 2009, * then the following terms are stored for this document: * "20090202", "200902" and "2009".</li> * <li>In case a date range search is done, then all possible matches for the * provided rage are created as search terms and matched with the document terms.</li> * <li>Consider the following use case: You want to find out if a resource has been changed * in the time between November 29, 2007 and March 01, 2009. * One term to match is simply "2008" because if a document * was modified in 2008, then it is clearly in the date range. * Other terms are "200712", "200901" and "200902", because all documents * modified in these months are also a certain matches. * Finally we need to add terms for "20071129", "20071130" and "20090301" to match the days in the * starting and final month.</li> * </ul> * * @param startDate start date of the range to search in * @param endDate end date of the range to search in * * @return a list of date terms for the optimized date range search */ public static List<String> getDateRangeSpan(long startDate, long endDate) { if (startDate > endDate) { // switch so that the end is always before the start long temp = endDate; endDate = startDate; startDate = temp; } List<String> result = new ArrayList<String>(100); // initialize calendars from the time value Calendar calStart = Calendar.getInstance(OpenCms.getLocaleManager().getTimeZone()); Calendar calEnd = Calendar.getInstance(calStart.getTimeZone()); calStart.setTimeInMillis(startDate); calEnd.setTimeInMillis(endDate); // get the required info to build the date range from the calendars int startDay = calStart.get(Calendar.DAY_OF_MONTH); int endDay = calEnd.get(Calendar.DAY_OF_MONTH); int maxDayInStartMonth = calStart.getActualMaximum(Calendar.DAY_OF_MONTH); int startMonth = calStart.get(Calendar.MONTH) + 1; int endMonth = calEnd.get(Calendar.MONTH) + 1; int startYear = calStart.get(Calendar.YEAR); int endYear = calEnd.get(Calendar.YEAR); // first add all full years in the date range result.addAll(getYearSpan(startYear + 1, endYear - 1)); if (startYear != endYear) { // different year, different month result.addAll(getMonthSpan(startMonth + 1, 12, startYear)); result.addAll(getMonthSpan(1, endMonth - 1, endYear)); result.addAll(getDaySpan(startDay, maxDayInStartMonth, startMonth, startYear)); result.addAll(getDaySpan(1, endDay, endMonth, endYear)); } else { if (startMonth != endMonth) { // same year, different month result.addAll(getMonthSpan(startMonth + 1, endMonth - 1, startYear)); result.addAll(getDaySpan(startDay, maxDayInStartMonth, startMonth, startYear)); result.addAll(getDaySpan(1, endDay, endMonth, endYear)); } else { // same year, same month result.addAll(getDaySpan(startDay, endDay, endMonth, endYear)); } } // sort the result, makes the range better readable in the debugger Collections.sort(result); return result; }
From source file:org.ambraproject.article.action.BrowseArticlesAction.java
private String browseDate() { Calendar startDate = Calendar.getInstance(); startDate.set(Calendar.HOUR_OF_DAY, 0); startDate.set(Calendar.MINUTE, 0); startDate.set(Calendar.SECOND, 0); startDate.set(Calendar.MILLISECOND, 0); Calendar endDate; boolean isLastDay = false; if (((startDateParam != null) && startDateParam.length() > 0) || ((endDateParam != null) && endDateParam.length() > 0)) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try {//from w w w. ja va 2 s . c o m if (startDateParam != null) { startDate.setTime(sdf.parse(startDateParam)); } else { startDate.setTimeInMillis(0); } endDate = Calendar.getInstance(); if (endDateParam != null) { endDate.setTime(sdf.parse(endDateParam)); } } catch (Exception e) { log.error("Failed to parse start / end Date params"); return ERROR; } } else { if (getYear() > UNSET && getMonth() > UNSET && getDay() > UNSET) { // user has clicked on a date link startDate.set(getYear(), getMonth() - 1, getDay()); endDate = (Calendar) startDate.clone(); } else if (getYear() > UNSET && getMonth() > UNSET) { // user has clicked on a month link startDate.set(getYear(), getMonth() - 1, 1); endDate = (Calendar) startDate.clone(); int lastDay = endDate.getActualMaximum(Calendar.DAY_OF_MONTH); endDate.set(Calendar.DAY_OF_MONTH, lastDay); } else if (getMonth() == PAST_MONTH) { // user has clicked on the past month link endDate = (Calendar) startDate.clone(); startDate.add(Calendar.MONTH, -1); } else if (getMonth() == PAST_3MON) { // user has clicked on the past 3 months link endDate = (Calendar) startDate.clone(); startDate.add(Calendar.MONTH, -3); } else if (getDay() == LAST_DAY) { // user has clicked on the past day link endDate = (Calendar) startDate.clone(); startDate.add(Calendar.DATE, -1); isLastDay = true; } else { // user has clicked on the past week link endDate = (Calendar) startDate.clone(); startDate.add(Calendar.DATE, -7); } } BrowseParameters params = new BrowseParameters(); params.setStartDate(startDate); params.setEndDate(endDate); params.setPageNum(this.startPage); params.setPageSize(this.pageSize); params.setJournalKey(this.getCurrentJournal()); params.setSort(this.sort); BrowseResult result = browseService.getArticlesByDate(params); // want the last day that we have articles published if (isLastDay) { while (result.getArticles() == null || (result.getArticles() != null && result.getArticles().size() == 0)) { startDate.add(Calendar.DAY_OF_MONTH, -1); params.setStartDate(startDate); result = browseService.getArticlesByDate(params); } } this.articleList = result.getArticles(); this.totalArticles = result.getTotal(); this.articleDates = browseService.getArticleDatesForJournal(this.getCurrentJournal()); this.subjectFacet = null; //When filtering by date, select all the subjects this.subjects = browseService.getSubjectsForJournal(this.getCurrentJournal()); return SUCCESS; }
From source file:com.baidu.rigel.biplatform.tesseract.meta.impl.TimeDimensionMemberServiceImpl.java
/** * ?//w ww . j ava2 s. c o m * * @param level * @param parentMember * @return */ private List<MiniCubeMember> genMembersFromOtherToWeek(Level level, Member parentMember) { List<MiniCubeMember> members = Lists.newArrayList(); String parentName = parentMember.getName(); String year = parentName.substring(0, 4); String month = parentName.substring(4, 6); int quarterIndex = Integer.valueOf(month) - 1; // Calendar cal = Calendar.getInstance(); Date now = cal.getTime(); // ? Date nowWeek = this.getFirstDayOfWeek(now); // ? cal.set(Calendar.YEAR, Integer.valueOf(year)); cal.set(Calendar.MONTH, Integer.valueOf(month) - 1); cal.set(Calendar.DATE, 1); cal.setFirstDayOfWeek(Calendar.MONDAY); SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd"); int count = 1; // Date firstDay = cal.getTime(); Date firstWeek = this.getFirstDayOfWeek(firstDay); // ? Date lastDay; Date lastWeek; int daysOfMonth; switch (parentMember.getLevel().getType()) { case TIME_YEARS: break; case TIME_QUARTERS: cal.add(Calendar.MONTH, 2); // ?? daysOfMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH); // ? cal.add(Calendar.DATE, daysOfMonth); lastDay = cal.getTime(); // lastWeek = this.getFirstDayOfWeek(lastDay); // // ??? if (nowWeek.before(lastWeek) || (nowWeek.compareTo(lastWeek) == 0)) { lastWeek = nowWeek; } cal.setTime(firstWeek); // ? while (cal.getTime().before(lastWeek) || (cal.getTime().compareTo(lastWeek) == 0)) { String day = sf.format(cal.getTime()); String caption = "" + (quarterIndex + 1) + "" + count + ""; caption = caption + day; MiniCubeMember dayMember = new MiniCubeMember(day); dayMember.setCaption(caption); dayMember.setLevel(level); dayMember.setParent(parentMember); dayMember.setName(day); dayMember.setVisible(true); for (int i = 0; i <= 6; i++) { dayMember.getQueryNodes().add(sf.format(cal.getTime())); cal.add(Calendar.DATE, 1); } members.add(dayMember); // cal.add(Calendar.DATE, 1); count++; } break; case TIME_MONTHS: daysOfMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH); // cal.add(Calendar.DATE, daysOfMonth); lastDay = cal.getTime(); // lastWeek = this.getFirstDayOfWeek(lastDay); // // ??? if (nowWeek.before(lastWeek) || (nowWeek.compareTo(lastWeek) == 0)) { lastWeek = nowWeek; } cal.setTime(firstWeek); // ? while (cal.getTime().before(lastWeek) || (cal.getTime().compareTo(lastWeek) == 0)) { String day = sf.format(cal.getTime()); String caption = month + "" + count + ""; MiniCubeMember dayMember = new MiniCubeMember(day); dayMember.setCaption(caption); dayMember.setLevel(level); dayMember.setParent(parentMember); dayMember.setName(day); dayMember.setVisible(true); for (int i = 0; i <= 6; i++) { dayMember.getQueryNodes().add(sf.format(cal.getTime())); cal.add(Calendar.DATE, 1); } members.add(dayMember); // cal.add(Calendar.DATE, 1); count++; } break; case TIME_WEEKS: break; case TIME_DAYS: break; default: } return members; }
From source file:org.kuali.kra.s2s.service.impl.S2SUtilServiceImpl.java
/** * /*from w ww .j a v a 2 s .c om*/ * This method computes the number of months between any 2 given * {@link Date} objects * * @param dateStart * starting date. * @param dateEnd * end date. * * @return number of months between the start date and end date. */ public BudgetDecimal getNumberOfMonths(Date dateStart, Date dateEnd) { BudgetDecimal monthCount = BudgetDecimal.ZERO; int fullMonthCount = 0; Calendar startDate = Calendar.getInstance(); Calendar endDate = Calendar.getInstance(); startDate.setTime(dateStart); endDate.setTime(dateEnd); startDate.clear(Calendar.HOUR); startDate.clear(Calendar.MINUTE); startDate.clear(Calendar.SECOND); startDate.clear(Calendar.MILLISECOND); endDate.clear(Calendar.HOUR); endDate.clear(Calendar.MINUTE); endDate.clear(Calendar.SECOND); endDate.clear(Calendar.MILLISECOND); if (startDate.after(endDate)) { return BudgetDecimal.ZERO; } int startMonthDays = startDate.getActualMaximum(Calendar.DATE) - startDate.get(Calendar.DATE); startMonthDays++; int startMonthMaxDays = startDate.getActualMaximum(Calendar.DATE); BudgetDecimal startMonthFraction = new BudgetDecimal(startMonthDays) .divide(new BudgetDecimal(startMonthMaxDays)); int endMonthDays = endDate.get(Calendar.DATE); int endMonthMaxDays = endDate.getActualMaximum(Calendar.DATE); BudgetDecimal endMonthFraction = new BudgetDecimal(endMonthDays).divide(new BudgetDecimal(endMonthMaxDays)); startDate.set(Calendar.DATE, 1); endDate.set(Calendar.DATE, 1); while (startDate.getTimeInMillis() < endDate.getTimeInMillis()) { startDate.set(Calendar.MONTH, startDate.get(Calendar.MONTH) + 1); fullMonthCount++; } fullMonthCount = fullMonthCount - 1; monthCount = monthCount.add(new BudgetDecimal(fullMonthCount)).add(startMonthFraction) .add(endMonthFraction); return monthCount; }
From source file:com.icesoft.faces.component.selectinputdate.SelectInputDateRenderer.java
private Calendar shiftYear(FacesContext facesContext, Calendar timeKeeper, int currentDay, int shift) { Calendar cal = copyCalendar(facesContext, timeKeeper); cal.set(Calendar.YEAR, cal.get(Calendar.YEAR) + shift); if (currentDay > cal.getActualMaximum(Calendar.DAY_OF_MONTH)) { currentDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH); }//w ww.jav a 2s . c o m cal.set(Calendar.DAY_OF_MONTH, currentDay); return cal; }
From source file:com.icesoft.faces.component.selectinputdate.SelectInputDateRenderer.java
private Calendar shiftMonth(FacesContext facesContext, Calendar timeKeeper, int currentDay, int shift) { Calendar cal = copyCalendar(facesContext, timeKeeper); cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) + shift); if (currentDay > cal.getActualMaximum(Calendar.DAY_OF_MONTH)) { currentDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH); }//from www. jav a 2 s.c o m cal.set(Calendar.DAY_OF_MONTH, currentDay); return cal; }
From source file:egovframework.oe1.cms.com.web.EgovOe1CalRestdeManageController.java
/** * ? ?/*from w w w.j a v a 2 s . c o m*/ * @param restde * @param model * @return "/cmm/sym/cal/EgovNormalDayCalendar" * @throws Exception */ @RequestMapping(value = "/com/EgovNormalDayCalendar.do") public String selectNormalDayCalendar(EgovOe1Restde restde, ModelMap model) throws Exception { Calendar cal = Calendar.getInstance(); if (restde.getYear() == null || restde.getYear().equals("")) { restde.setYear(Integer.toString(cal.get(Calendar.YEAR))); } if (restde.getMonth() == null || restde.getMonth().equals("")) { restde.setMonth(Integer.toString(cal.get(Calendar.MONTH) + 1)); } if (restde.getDay() == null || restde.getDay().equals("")) { restde.setDay(Integer.toString(cal.get(Calendar.DATE))); } int iYear = Integer.parseInt(restde.getYear()); int iMonth = Integer.parseInt(restde.getMonth()); int iDay = Integer.parseInt(restde.getDay()); if (iMonth < 1) { iYear--; iMonth = 12; } if (iMonth > 12) { iYear++; iMonth = 1; } if (iYear < 1) { iYear = 1; iMonth = 1; } if (iYear > 9999) { iYear = 9999; iMonth = 12; } restde.setYear(Integer.toString(iYear)); restde.setMonth(Integer.toString(iMonth)); cal.set(iYear, iMonth - 1, iDay); restde.setStartWeekMonth(cal.get(Calendar.DAY_OF_WEEK)); cal.set(iYear, iMonth - 1, Integer.parseInt(restde.getDay())); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DAY_OF_MONTH)); restde.setYear(Integer.toString(cal.get(cal.YEAR))); restde.setMonth(Integer.toString(cal.get(cal.MONTH) + 1)); restde.setDay(Integer.toString(cal.get(cal.DAY_OF_MONTH))); restde.setWeek(cal.get(cal.DAY_OF_WEEK)); restde.setLastDayMonth(cal.getActualMaximum(Calendar.DATE)); List CalInfoList = restdeManageService.selectNormalDayCal(restde); List NormalWeekRestdeList = restdeManageService.selectNormalDayRestde(restde); model.addAttribute("resultList", CalInfoList); model.addAttribute("RestdeList", NormalWeekRestdeList); return "/cms/com/EgovNormalDayCalendar"; }