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
/** * ? //www . ja v a2s . co m * @param restde * @param model * @return "/cmm/sym/cal/EgovNormalWeekCalendar" * @throws Exception */ @RequestMapping(value = "/com/EgovNormalWeekCalendar.do") public String selectNormalWeekCalendar(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()); 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, 1); 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)); int iStartWeek = restde.getStartWeekMonth(); int iLastDate = restde.getLastDayMonth(); int iDayWeek = cal.get(Calendar.DAY_OF_WEEK); int iMaxWeeks = (int) Math.floor(iLastDate / 7); iMaxWeeks = iMaxWeeks + (int) Math.ceil(((iLastDate - iMaxWeeks * 7) + iStartWeek - 1) / 7.0); restde.setMaxWeeks(iMaxWeeks); if (iMaxWeeks < restde.getWeeks()) { restde.setWeeks(iMaxWeeks); } EgovOe1Restde vo = new EgovOe1Restde(); Calendar weekCal = Calendar.getInstance(); weekCal.setTime(cal.getTime()); if (restde.getWeeks() != 0) { weekCal.set(weekCal.DATE, (restde.getWeeks() - 1) * 7 + 1); if (restde.getWeeks() > 1) { iDayWeek = weekCal.get(weekCal.DAY_OF_WEEK); weekCal.add(weekCal.DATE, (-1) * (iDayWeek - 1)); } restde.setDay(Integer.toString(weekCal.get(weekCal.DAY_OF_MONTH) + 1)); } iDayWeek = weekCal.get(weekCal.DAY_OF_WEEK); // ?? weekCal.add(weekCal.DATE, (-1) * (iDayWeek - 1)); vo.setYear(Integer.toString(weekCal.get(weekCal.YEAR))); vo.setMonth(Integer.toString(weekCal.get(weekCal.MONTH) + 1)); vo.setDay(Integer.toString(weekCal.get(weekCal.DAY_OF_MONTH))); vo.setWeek(weekCal.get(weekCal.DAY_OF_WEEK)); List CalInfoList_1 = restdeManageService.selectNormalDayCal(vo); List NormalWeekRestdeList_1 = restdeManageService.selectNormalDayRestde(vo); // ? weekCal.add(weekCal.DATE, 1); vo.setYear(Integer.toString(weekCal.get(weekCal.YEAR))); vo.setMonth(Integer.toString(weekCal.get(weekCal.MONTH) + 1)); vo.setDay(Integer.toString(weekCal.get(weekCal.DAY_OF_MONTH))); vo.setWeek(weekCal.get(weekCal.DAY_OF_WEEK)); List CalInfoList_2 = restdeManageService.selectNormalDayCal(vo); List NormalWeekRestdeList_2 = restdeManageService.selectNormalDayRestde(vo); // ? weekCal.add(weekCal.DATE, 1); vo.setYear(Integer.toString(weekCal.get(weekCal.YEAR))); vo.setMonth(Integer.toString(weekCal.get(weekCal.MONTH) + 1)); vo.setDay(Integer.toString(weekCal.get(weekCal.DAY_OF_MONTH))); vo.setWeek(weekCal.get(weekCal.DAY_OF_WEEK)); List CalInfoList_3 = restdeManageService.selectNormalDayCal(vo); List NormalWeekRestdeList_3 = restdeManageService.selectNormalDayRestde(vo); // ? weekCal.add(weekCal.DATE, 1); vo.setYear(Integer.toString(weekCal.get(weekCal.YEAR))); vo.setMonth(Integer.toString(weekCal.get(weekCal.MONTH) + 1)); vo.setDay(Integer.toString(weekCal.get(weekCal.DAY_OF_MONTH))); vo.setWeek(weekCal.get(weekCal.DAY_OF_WEEK)); List CalInfoList_4 = restdeManageService.selectNormalDayCal(vo); List NormalWeekRestdeList_4 = restdeManageService.selectNormalDayRestde(vo); // ? weekCal.add(weekCal.DATE, 1); vo.setYear(Integer.toString(weekCal.get(weekCal.YEAR))); vo.setMonth(Integer.toString(weekCal.get(weekCal.MONTH) + 1)); vo.setDay(Integer.toString(weekCal.get(weekCal.DAY_OF_MONTH))); vo.setWeek(weekCal.get(weekCal.DAY_OF_WEEK)); List CalInfoList_5 = restdeManageService.selectNormalDayCal(vo); List NormalWeekRestdeList_5 = restdeManageService.selectNormalDayRestde(vo); // ? weekCal.add(weekCal.DATE, 1); vo.setYear(Integer.toString(weekCal.get(weekCal.YEAR))); vo.setMonth(Integer.toString(weekCal.get(weekCal.MONTH) + 1)); vo.setDay(Integer.toString(weekCal.get(weekCal.DAY_OF_MONTH))); vo.setWeek(weekCal.get(weekCal.DAY_OF_WEEK)); List CalInfoList_6 = restdeManageService.selectNormalDayCal(vo); List NormalWeekRestdeList_6 = restdeManageService.selectNormalDayRestde(vo); // ? weekCal.add(weekCal.DATE, 1); vo.setYear(Integer.toString(weekCal.get(weekCal.YEAR))); vo.setMonth(Integer.toString(weekCal.get(weekCal.MONTH) + 1)); vo.setDay(Integer.toString(weekCal.get(weekCal.DAY_OF_MONTH))); vo.setWeek(weekCal.get(weekCal.DAY_OF_WEEK)); List CalInfoList_7 = restdeManageService.selectNormalDayCal(vo); List NormalWeekRestdeList_7 = restdeManageService.selectNormalDayRestde(vo); 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("RestdeList_1", NormalWeekRestdeList_1); model.addAttribute("RestdeList_2", NormalWeekRestdeList_2); model.addAttribute("RestdeList_3", NormalWeekRestdeList_3); model.addAttribute("RestdeList_4", NormalWeekRestdeList_4); model.addAttribute("RestdeList_5", NormalWeekRestdeList_5); model.addAttribute("RestdeList_6", NormalWeekRestdeList_6); model.addAttribute("RestdeList_7", NormalWeekRestdeList_7); List CalInfoList = restdeManageService.selectNormalDayCal(restde); model.addAttribute("resultList", CalInfoList); return "/cms/com/EgovNormalWeekCalendar"; }
From source file:ca.uhn.fhir.model.primitive.BaseDateTimeDt.java
@Override protected Date parse(String theValue) throws DataFormatException { Calendar cal = new GregorianCalendar(0, 0, 0); cal.setTimeZone(TimeZone.getDefault()); String value = theValue;/*from w w w.java 2 s . c om*/ boolean fractionalSecondsSet = false; if (value.length() > 0 && (value.charAt(0) == ' ' || value.charAt(value.length() - 1) == ' ')) { value = value.trim(); } int length = value.length(); if (length == 0) { return null; } if (length < 4) { throwBadDateFormat(value); } TemporalPrecisionEnum precision = null; cal.set(Calendar.YEAR, parseInt(value, value.substring(0, 4), 0, 9999)); precision = TemporalPrecisionEnum.YEAR; if (length > 4) { validateCharAtIndexIs(value, 4, '-'); validateLengthIsAtLeast(value, 7); int monthVal = parseInt(value, value.substring(5, 7), 1, 12) - 1; cal.set(Calendar.MONTH, monthVal); precision = TemporalPrecisionEnum.MONTH; if (length > 7) { validateCharAtIndexIs(value, 7, '-'); validateLengthIsAtLeast(value, 10); cal.set(Calendar.DATE, 1); // for some reason getActualMaximum works incorrectly if date isn't set int actualMaximum = cal.getActualMaximum(Calendar.DAY_OF_MONTH); cal.set(Calendar.DAY_OF_MONTH, parseInt(value, value.substring(8, 10), 1, actualMaximum)); precision = TemporalPrecisionEnum.DAY; if (length > 10) { validateLengthIsAtLeast(value, 17); validateCharAtIndexIs(value, 10, 'T'); // yyyy-mm-ddThh:mm:ss int offsetIdx = getOffsetIndex(value); String time; if (offsetIdx == -1) { //throwBadDateFormat(theValue); // No offset - should this be an error? time = value.substring(11); } else { time = value.substring(11, offsetIdx); String offsetString = value.substring(offsetIdx); setTimeZone(value, offsetString); cal.setTimeZone(getTimeZone()); } int timeLength = time.length(); validateCharAtIndexIs(value, 13, ':'); cal.set(Calendar.HOUR_OF_DAY, parseInt(value, value.substring(11, 13), 0, 23)); cal.set(Calendar.MINUTE, parseInt(value, value.substring(14, 16), 0, 59)); precision = TemporalPrecisionEnum.MINUTE; if (timeLength > 5) { validateLengthIsAtLeast(value, 19); validateCharAtIndexIs(value, 16, ':'); // yyyy-mm-ddThh:mm:ss cal.set(Calendar.SECOND, parseInt(value, value.substring(17, 19), 0, 59)); precision = TemporalPrecisionEnum.SECOND; if (timeLength > 8) { validateCharAtIndexIs(value, 19, '.'); // yyyy-mm-ddThh:mm:ss.SSSS validateLengthIsAtLeast(value, 20); int endIndex = getOffsetIndex(value); if (endIndex == -1) { endIndex = value.length(); } int millis; String millisString; if (endIndex > 23) { myFractionalSeconds = value.substring(20, endIndex); fractionalSecondsSet = true; endIndex = 23; millisString = value.substring(20, endIndex); millis = parseInt(value, millisString, 0, 999); } else { millisString = value.substring(20, endIndex); millis = parseInt(value, millisString, 0, 999); myFractionalSeconds = millisString; fractionalSecondsSet = true; } if (millisString.length() == 1) { millis = millis * 100; } else if (millisString.length() == 2) { millis = millis * 10; } cal.set(Calendar.MILLISECOND, millis); precision = TemporalPrecisionEnum.MILLI; } } } } else { cal.set(Calendar.DATE, 1); } } else { cal.set(Calendar.DATE, 1); } if (fractionalSecondsSet == false) { myFractionalSeconds = ""; } setPrecision(precision); return cal.getTime(); }
From source file:controllers.core.RoadmapController.java
/** * The details of a cell of the the capacity forecast table. * /*from w ww. j ava 2s.c om*/ * @param objectType * the object type (org unit or competency) * @param objectId * the object id (org unit id or competency id) * @param year * the year * @param month * the month */ public Result simulatorCapacityForecastCellDetailsFragment(String objectType, Long objectId, Integer year, Integer month) { try { OrgUnit orgUnit = null; Competency competency = null; Class<?> cls = Class.forName(objectType); if (cls.equals(OrgUnit.class)) { orgUnit = OrgUnitDao.getOrgUnitById(objectId); } else if (cls.equals(Competency.class)) { competency = ActorDao.getCompetencyById(objectId); } List<String> ids = FilterConfig.getIdsFromRequest(request()); /** * Compute the period according to the selected year. */ Calendar monthStartDay = Calendar.getInstance(); monthStartDay.set(Calendar.YEAR, year.intValue()); monthStartDay.set(Calendar.MONTH, month.intValue()); monthStartDay.set(Calendar.DAY_OF_MONTH, 1); monthStartDay.set(Calendar.HOUR_OF_DAY, 0); monthStartDay.set(Calendar.MINUTE, 0); monthStartDay.set(Calendar.SECOND, 0); monthStartDay.set(Calendar.MILLISECOND, 0); Calendar monthEndDay = Calendar.getInstance(); monthEndDay.set(Calendar.YEAR, year.intValue()); monthEndDay.set(Calendar.MONTH, month.intValue()); monthEndDay.set(Calendar.DAY_OF_MONTH, monthEndDay.getActualMaximum(Calendar.DAY_OF_MONTH)); monthEndDay.set(Calendar.HOUR_OF_DAY, 23); monthEndDay.set(Calendar.MINUTE, 59); monthEndDay.set(Calendar.SECOND, 59); monthEndDay.set(Calendar.MILLISECOND, 999); /** * Get the PE allocations. */ List<PortfolioEntryResourcePlanAllocatedOrgUnit> allocatedOrgUnits = new ArrayList<>(); List<PortfolioEntryResourcePlanAllocatedCompetency> allocatedCompetencies = new ArrayList<>(); List<PortfolioEntryResourcePlanAllocatedActor> allocatedActors = new ArrayList<>(); for (String idString : ids) { Long id = Long.valueOf(idString); if (orgUnit != null) { allocatedOrgUnits .addAll(PortfolioEntryResourcePlanDAO.getPEResourcePlanAllocatedOrgUnitAsListByPE(id, monthStartDay.getTime(), monthEndDay.getTime(), false, objectId)); allocatedActors.addAll(PortfolioEntryResourcePlanDAO.getPEPlanAllocatedActorAsListByPE(id, monthStartDay.getTime(), monthEndDay.getTime(), false, objectId, null)); } if (competency != null) { allocatedCompetencies .addAll(PortfolioEntryResourcePlanDAO.getPEPlanAllocatedCompetencyAsListByPE(id, monthStartDay.getTime(), monthEndDay.getTime(), false, objectId)); allocatedActors.addAll(PortfolioEntryResourcePlanDAO.getPEPlanAllocatedActorAsListByPE(id, monthStartDay.getTime(), monthEndDay.getTime(), false, null, objectId)); } } /** * Compute the capacities for the objet (org unit or competency) and * actor allocations and group them by actor. */ Map<Long, CapacityDetails> capacityDetailsRows = new HashMap<>(); if (orgUnit != null) { // There is exactly one org unit. CapacityDetails capacityDetailsOrgUnit = new CapacityDetails(orgUnit); capacityDetailsRows.put(0L, capacityDetailsOrgUnit); for (PortfolioEntryResourcePlanAllocatedOrgUnit allocatedOrgUnit : allocatedOrgUnits) { computeCapacityDetails(allocatedOrgUnit.startDate, allocatedOrgUnit.endDate, getAllocatedDays(allocatedOrgUnit.days, allocatedOrgUnit.forecastDays), year, month, false, allocatedOrgUnit.isConfirmed, capacityDetailsOrgUnit); } } if (competency != null) { // There is exactly one competency. CapacityDetails capacityDetailsCompetency = new CapacityDetails(competency); capacityDetailsRows.put(0L, capacityDetailsCompetency); for (PortfolioEntryResourcePlanAllocatedCompetency allocatedCompetency : allocatedCompetencies) { computeCapacityDetails(allocatedCompetency.startDate, allocatedCompetency.endDate, allocatedCompetency.days, year, month, false, allocatedCompetency.isConfirmed, capacityDetailsCompetency); } } // Actor if (orgUnit != null) { for (Actor actor : orgUnit.actors) { capacityDetailsRows.put(actor.id, new CapacityDetails(actor)); } } if (competency != null) { for (Actor actor : competency.actorsWithDefault) { capacityDetailsRows.put(actor.id, new CapacityDetails(actor)); } } for (PortfolioEntryResourcePlanAllocatedActor allocatedActor : allocatedActors) { CapacityDetails capacityDetailsActor = capacityDetailsRows.get(allocatedActor.actor.id); computeCapacityDetails(allocatedActor.startDate, allocatedActor.endDate, getAllocatedDays(allocatedActor.days, allocatedActor.forecastDays), year, month, false, allocatedActor.isConfirmed, capacityDetailsActor); } /** * Get and compute the activity capacities and the actor available * capacities. */ for (Entry<Long, CapacityDetails> entry : capacityDetailsRows.entrySet()) { if (!entry.getKey().equals(0L)) { CapacityDetails capacityDetails = entry.getValue(); // Get the activity allocations. List<TimesheetActivityAllocatedActor> allocatedActivities = TimesheetDao .getTimesheetActivityAllocatedActorAsListByActorAndPeriod(capacityDetails.getActor().id, monthStartDay.getTime(), monthEndDay.getTime()); // Compute the activity allocations. for (TimesheetActivityAllocatedActor allocatedActivity : allocatedActivities) { computeCapacityDetails(allocatedActivity.startDate, allocatedActivity.endDate, allocatedActivity.days, year, month, true, true, capacityDetails); } // Get the available actor capacity ActorCapacity actorCapacity = ActorDao.getActorCapacityByActorAndPeriod( capacityDetails.getActor().id, year, month.intValue() + 1); if (actorCapacity != null) { capacityDetails.addAvailable(actorCapacity.value); } } } // get the month name Calendar cal = Calendar.getInstance(); cal.set(Calendar.MONTH, month); // compute the chart BasicBar basicBarChart = new BasicBar(); for (Entry<Long, CapacityDetails> entry : capacityDetailsRows.entrySet()) { if (!entry.getKey().equals(0L)) { basicBarChart.addCategory(entry.getValue().getActor().getName()); } } BasicBar.Elem elem1 = new BasicBar.Elem( Msg.get("core.roadmap.simulator.capacity_forecast.planned.label")); BasicBar.Elem elem2 = new BasicBar.Elem( Msg.get("core.roadmap.simulator.capacity_forecast.available.label")); for (Entry<Long, CapacityDetails> entry : capacityDetailsRows.entrySet()) { if (!entry.getKey().equals(0L)) { CapacityDetails capacityDetails = entry.getValue(); elem1.addValue(capacityDetails.getPlannedActivity() + capacityDetails.getPlannedPortfolioEntryConfirmed() + capacityDetails.getPlannedPortfolioEntryNotConfirmed()); elem2.addValue(capacityDetails.getAvailable()); } } basicBarChart.addElem(elem1); basicBarChart.addElem(elem2); return ok(views.html.core.roadmap.roadmap_capacity_forecast_cell_details_fragment.render(orgUnit, competency, new SimpleDateFormat("MMMM").format(cal.getTime()), new ArrayList<CapacityDetails>(capacityDetailsRows.values()), basicBarChart)); } catch (Exception e) { return ControllersUtils.logAndReturnUnexpectedError(e, log, getConfiguration(), getI18nMessagesPlugin()); } }
From source file:Dates.java
/** * Date Arithmetic function (date2 - date1). subtract a date from another * date, return the difference as the required fields. E.g. if specified * Calendar.Date, the smaller range of fields is ignored and this method * return the difference of days./*from ww w. j av a 2s . co m*/ * * @param date2 * The date2. * @param tz * The time zone. * @param field * The time field; e.g., Calendar.DATE, Calendar.YEAR, it's default * value is Calendar.DATE * @param date1 * The date1. */ public static final long subtract(Date date2, TimeZone tz, int field, Date date1) { if (tz == null) tz = TimeZones.getCurrent(); boolean negative = false; if (date1.after(date2)) { negative = true; final Date d = date1; date1 = date2; date2 = d; } final Calendar cal1 = Calendar.getInstance(tz); cal1.setTimeInMillis(date1.getTime());// don't call cal.setTime(Date) which // will reset the TimeZone. final Calendar cal2 = Calendar.getInstance(tz); cal2.setTimeInMillis(date2.getTime());// don't call cal.setTime(Date) which // will reset the TimeZone. int year1 = cal1.get(Calendar.YEAR); int year2 = cal2.get(Calendar.YEAR); switch (field) { case Calendar.YEAR: { return negative ? (year1 - year2) : (year2 - year1); } case Calendar.MONTH: { int month1 = cal1.get(Calendar.MONTH); int month2 = cal2.get(Calendar.MONTH); int months = 12 * (year2 - year1) + month2 - month1; return negative ? -months : months; } case Calendar.HOUR: { long time1 = date1.getTime(); long time2 = date2.getTime(); long min1 = (time1 < 0 ? (time1 - (1000 * 60 * 60 - 1)) : time1) / (1000 * 60 * 60); long min2 = (time2 < 0 ? (time2 - (1000 * 60 * 60 - 1)) : time2) / (1000 * 60 * 60); return negative ? (min1 - min2) : (min2 - min1); } case Calendar.MINUTE: { long time1 = date1.getTime(); long time2 = date2.getTime(); long min1 = (time1 < 0 ? (time1 - (1000 * 60 - 1)) : time1) / (1000 * 60); long min2 = (time2 < 0 ? (time2 - (1000 * 60 - 1)) : time2) / (1000 * 60); return negative ? (min1 - min2) : (min2 - min1); } case Calendar.SECOND: { long time1 = date1.getTime(); long time2 = date2.getTime(); long sec1 = (time1 < 0 ? (time1 - (1000 - 1)) : time1) / 1000; long sec2 = (time2 < 0 ? (time2 - (1000 - 1)) : time2) / 1000; return negative ? (sec1 - sec2) : (sec2 - sec1); } case Calendar.MILLISECOND: { return negative ? (date1.getTime() - date2.getTime()) : (date2.getTime() - date1.getTime()); } case Calendar.DATE: default: /* default, like -1 */ { int day1 = cal1.get(Calendar.DAY_OF_YEAR); int day2 = cal2.get(Calendar.DAY_OF_YEAR); int maxDay1 = year1 == year2 ? 0 : cal1.getActualMaximum(Calendar.DAY_OF_YEAR); int days = maxDay1 - day1 + day2; final Calendar cal = Calendar.getInstance(tz); for (int year = year1 + 1; year < year2; year++) { cal.set(Calendar.YEAR, year); days += cal.getActualMaximum(Calendar.DAY_OF_YEAR); } return negative ? -days : days; } } }
From source file:org.apache.jsp.html.portlet.calendar.tabs1_jsp.java
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null;/*w w w.java 2 s. c o m*/ HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); // liferay-theme:defineObjects com.liferay.taglib.theme.DefineObjectsTag _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 = (com.liferay.taglib.theme.DefineObjectsTag) _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .get(com.liferay.taglib.theme.DefineObjectsTag.class); _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setPageContext(_jspx_page_context); _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setParent(null); int _jspx_eval_liferay_002dtheme_005fdefineObjects_005f0 = _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 .doStartTag(); if (_jspx_th_liferay_002dtheme_005fdefineObjects_005f0 .doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0); return; } _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0); com.liferay.portal.theme.ThemeDisplay themeDisplay = null; com.liferay.portal.model.Company company = null; com.liferay.portal.model.Account account = null; com.liferay.portal.model.User user = null; com.liferay.portal.model.User realUser = null; com.liferay.portal.model.Contact contact = null; com.liferay.portal.model.Layout layout = null; java.util.List layouts = null; java.lang.Long plid = null; com.liferay.portal.model.LayoutTypePortlet layoutTypePortlet = null; java.lang.Long scopeGroupId = null; com.liferay.portal.security.permission.PermissionChecker permissionChecker = null; java.util.Locale locale = null; java.util.TimeZone timeZone = null; com.liferay.portal.model.Theme theme = null; com.liferay.portal.model.ColorScheme colorScheme = null; com.liferay.portal.theme.PortletDisplay portletDisplay = null; java.lang.Long portletGroupId = null; themeDisplay = (com.liferay.portal.theme.ThemeDisplay) _jspx_page_context.findAttribute("themeDisplay"); company = (com.liferay.portal.model.Company) _jspx_page_context.findAttribute("company"); account = (com.liferay.portal.model.Account) _jspx_page_context.findAttribute("account"); user = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("user"); realUser = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("realUser"); contact = (com.liferay.portal.model.Contact) _jspx_page_context.findAttribute("contact"); layout = (com.liferay.portal.model.Layout) _jspx_page_context.findAttribute("layout"); layouts = (java.util.List) _jspx_page_context.findAttribute("layouts"); plid = (java.lang.Long) _jspx_page_context.findAttribute("plid"); layoutTypePortlet = (com.liferay.portal.model.LayoutTypePortlet) _jspx_page_context .findAttribute("layoutTypePortlet"); scopeGroupId = (java.lang.Long) _jspx_page_context.findAttribute("scopeGroupId"); permissionChecker = (com.liferay.portal.security.permission.PermissionChecker) _jspx_page_context .findAttribute("permissionChecker"); locale = (java.util.Locale) _jspx_page_context.findAttribute("locale"); timeZone = (java.util.TimeZone) _jspx_page_context.findAttribute("timeZone"); theme = (com.liferay.portal.model.Theme) _jspx_page_context.findAttribute("theme"); colorScheme = (com.liferay.portal.model.ColorScheme) _jspx_page_context.findAttribute("colorScheme"); portletDisplay = (com.liferay.portal.theme.PortletDisplay) _jspx_page_context .findAttribute("portletDisplay"); portletGroupId = (java.lang.Long) _jspx_page_context.findAttribute("portletGroupId"); out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); // portlet:defineObjects com.liferay.taglib.portlet.DefineObjectsTag _jspx_th_portlet_005fdefineObjects_005f0 = (com.liferay.taglib.portlet.DefineObjectsTag) _005fjspx_005ftagPool_005fportlet_005fdefineObjects_005fnobody .get(com.liferay.taglib.portlet.DefineObjectsTag.class); _jspx_th_portlet_005fdefineObjects_005f0.setPageContext(_jspx_page_context); _jspx_th_portlet_005fdefineObjects_005f0.setParent(null); int _jspx_eval_portlet_005fdefineObjects_005f0 = _jspx_th_portlet_005fdefineObjects_005f0.doStartTag(); if (_jspx_th_portlet_005fdefineObjects_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fportlet_005fdefineObjects_005fnobody .reuse(_jspx_th_portlet_005fdefineObjects_005f0); return; } _005fjspx_005ftagPool_005fportlet_005fdefineObjects_005fnobody .reuse(_jspx_th_portlet_005fdefineObjects_005f0); javax.portlet.ActionRequest actionRequest = null; javax.portlet.ActionResponse actionResponse = null; javax.portlet.EventRequest eventRequest = null; javax.portlet.EventResponse eventResponse = null; javax.portlet.PortletConfig portletConfig = null; java.lang.String portletName = null; javax.portlet.PortletPreferences portletPreferences = null; java.util.Map portletPreferencesValues = null; javax.portlet.PortletSession portletSession = null; java.util.Map portletSessionScope = null; javax.portlet.RenderRequest renderRequest = null; javax.portlet.RenderResponse renderResponse = null; javax.portlet.ResourceRequest resourceRequest = null; javax.portlet.ResourceResponse resourceResponse = null; actionRequest = (javax.portlet.ActionRequest) _jspx_page_context.findAttribute("actionRequest"); actionResponse = (javax.portlet.ActionResponse) _jspx_page_context.findAttribute("actionResponse"); eventRequest = (javax.portlet.EventRequest) _jspx_page_context.findAttribute("eventRequest"); eventResponse = (javax.portlet.EventResponse) _jspx_page_context.findAttribute("eventResponse"); portletConfig = (javax.portlet.PortletConfig) _jspx_page_context.findAttribute("portletConfig"); portletName = (java.lang.String) _jspx_page_context.findAttribute("portletName"); portletPreferences = (javax.portlet.PortletPreferences) _jspx_page_context .findAttribute("portletPreferences"); portletPreferencesValues = (java.util.Map) _jspx_page_context.findAttribute("portletPreferencesValues"); portletSession = (javax.portlet.PortletSession) _jspx_page_context.findAttribute("portletSession"); portletSessionScope = (java.util.Map) _jspx_page_context.findAttribute("portletSessionScope"); renderRequest = (javax.portlet.RenderRequest) _jspx_page_context.findAttribute("renderRequest"); renderResponse = (javax.portlet.RenderResponse) _jspx_page_context.findAttribute("renderResponse"); resourceRequest = (javax.portlet.ResourceRequest) _jspx_page_context.findAttribute("resourceRequest"); resourceResponse = (javax.portlet.ResourceResponse) _jspx_page_context .findAttribute("resourceResponse"); out.write('\n'); out.write('\n'); WindowState windowState = null; PortletMode portletMode = null; PortletURL currentURLObj = null; if (renderRequest != null) { windowState = renderRequest.getWindowState(); portletMode = renderRequest.getPortletMode(); currentURLObj = PortletURLUtil.getCurrent(renderRequest, renderResponse); } else if (resourceRequest != null) { windowState = resourceRequest.getWindowState(); portletMode = resourceRequest.getPortletMode(); currentURLObj = PortletURLUtil.getCurrent(resourceRequest, resourceResponse); } String currentURL = currentURLObj.toString(); //String currentURL = PortalUtil.getCurrentURL(request); out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); PortletPreferences preferences = renderRequest.getPreferences(); String portletResource = ParamUtil.getString(request, "portletResource"); if (Validator.isNotNull(portletResource)) { preferences = PortletPreferencesFactoryUtil.getPortletSetup(request, portletResource); } String tabs1Names = "summary,day,week,month,year,events"; if (CalendarPermission.contains(permissionChecker, scopeGroupId, ActionKeys.EXPORT_ALL_EVENTS) || CalendarPermission.contains(permissionChecker, scopeGroupId, ActionKeys.ADD_EVENT)) { tabs1Names += ",export-import"; } String[] tabs1NamesArray = StringUtil.split(tabs1Names); String tabs1Default = preferences.getValue("tabs1-default", tabs1NamesArray[0]); String summaryTabOrientation = preferences.getValue("summary-tab-orientation", "horizontal"); boolean summaryTabShowMiniMonth = GetterUtil .getBoolean(preferences.getValue("summary-tab-show-mini-month", "true")); boolean summaryTabShowTodaysEvents = GetterUtil .getBoolean(preferences.getValue("summary-tab-show-todays-events", "true")); boolean enableComments = PropsValues.CALENDAR_EVENT_COMMENTS_ENABLED && GetterUtil.getBoolean(preferences.getValue("enable-comments", null), true); String monthParam = request.getParameter("month"); String dayParam = request.getParameter("day"); String yearParam = request.getParameter("year"); Calendar selCal = CalendarFactoryUtil.getCalendar(timeZone, locale); try { selCal.set(Calendar.YEAR, Integer.parseInt(yearParam)); } catch (NumberFormatException nfe) { } try { if (dayParam != null) { selCal.set(Calendar.DATE, 1); } selCal.set(Calendar.MONTH, Integer.parseInt(monthParam)); } catch (NumberFormatException nfe) { } try { int maxDayOfMonth = selCal.getActualMaximum(Calendar.DATE); int dayParamInt = Integer.parseInt(dayParam); if (dayParamInt > maxDayOfMonth) { dayParamInt = maxDayOfMonth; } selCal.set(Calendar.DATE, dayParamInt); } catch (NumberFormatException nfe) { } int selMonth = selCal.get(Calendar.MONTH); int selDay = selCal.get(Calendar.DATE); int selYear = selCal.get(Calendar.YEAR); Calendar curCal = CalendarFactoryUtil.getCalendar(timeZone, locale); int curMonth = curCal.get(Calendar.MONTH); int curDay = curCal.get(Calendar.DATE); int curYear = curCal.get(Calendar.YEAR); int[] monthIds = CalendarUtil.getMonthIds(); String[] months = CalendarUtil.getMonths(locale); String[] days = CalendarUtil.getDays(locale); Format dateFormatDate = FastDateFormatFactoryUtil.getDate(locale); Format dateFormatDateTime = FastDateFormatFactoryUtil.getDateTime(locale); Format dateFormatTime = FastDateFormatFactoryUtil.getTime(locale); DateFormat dateFormatISO8601 = DateUtil.getISO8601Format(); out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); String tabs1 = ParamUtil.getString(request, "tabs1", tabs1Default); PortletURL tabs1URL = renderResponse.createRenderURL(); tabs1URL.setParameter("struts_action", "/calendar/view"); tabs1URL.setParameter("month", String.valueOf(selMonth)); tabs1URL.setParameter("day", String.valueOf(selDay)); tabs1URL.setParameter("year", String.valueOf(selYear)); out.write('\n'); out.write('\n'); // liferay-ui:tabs com.liferay.taglib.ui.TabsTag _jspx_th_liferay_002dui_005ftabs_005f0 = (com.liferay.taglib.ui.TabsTag) _005fjspx_005ftagPool_005fliferay_002dui_005ftabs_0026_005fvalue_005furl_005fnames_005fnobody .get(com.liferay.taglib.ui.TabsTag.class); _jspx_th_liferay_002dui_005ftabs_005f0.setPageContext(_jspx_page_context); _jspx_th_liferay_002dui_005ftabs_005f0.setParent(null); // /html/portlet/calendar/tabs1.jsp(30,0) name = names type = null reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_liferay_002dui_005ftabs_005f0.setNames(tabs1Names); // /html/portlet/calendar/tabs1.jsp(30,0) name = url type = null reqTime = true required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_liferay_002dui_005ftabs_005f0.setUrl(tabs1URL.toString()); // /html/portlet/calendar/tabs1.jsp(30,0) name = value type = null reqTime = true required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_liferay_002dui_005ftabs_005f0.setValue(tabs1); int _jspx_eval_liferay_002dui_005ftabs_005f0 = _jspx_th_liferay_002dui_005ftabs_005f0.doStartTag(); if (_jspx_th_liferay_002dui_005ftabs_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fliferay_002dui_005ftabs_0026_005fvalue_005furl_005fnames_005fnobody .reuse(_jspx_th_liferay_002dui_005ftabs_005f0); return; } _005fjspx_005ftagPool_005fliferay_002dui_005ftabs_0026_005fvalue_005furl_005fnames_005fnobody .reuse(_jspx_th_liferay_002dui_005ftabs_005f0); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
From source file:forms.FormFluxodeCaixa.java
public void verificaFiltroData() { int posicao = comboFiltroData.getSelectedIndex(); System.out.println("posicao" + posicao); Calendar c = Calendar.getInstance(); switch (posicao) { case 0:/*from w w w . j a v a 2 s . c o m*/ txtDataInicial.setDate(c.getTime()); txtDataFinal.setDate(c.getTime()); break; case 1: c.set(Calendar.DAY_OF_MONTH, 1); txtDataInicial.setDate(c.getTime()); c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH)); txtDataFinal.setDate(c.getTime()); break; case 2: break; } // controle semanal // c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); // // txtDataInicial.setDate(c.getTime()); // // c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); // // txtDataFinal.setDate(c.getTime()); // // }
From source file:com.marcohc.robotocalendar.RobotoCalendarView.java
public void updateBackgroundSelectDays() { if (startDay != null && endDay != null) { Calendar auxCalendar = Calendar.getInstance(locale); auxCalendar.setTime(currentCalendar.getTime()); auxCalendar.set(Calendar.DAY_OF_MONTH, 1); auxCalendar.set(Calendar.HOUR_OF_DAY, 0); auxCalendar.set(Calendar.MINUTE, 0); // set minute in hour auxCalendar.set(Calendar.SECOND, 0); // set second in minute auxCalendar.set(Calendar.MILLISECOND, 0); Calendar startCalendar = getCurrentCalendar(); startCalendar.setTime(startDay); Calendar endCalendar = getCurrentCalendar(); endCalendar.setTime(endDay);/* w ww . j ava 2 s . co m*/ if (auxCalendar.compareTo(endCalendar) > 0) return; if (auxCalendar.compareTo(startCalendar) > 0) { startCalendar = auxCalendar; if (startCalendar.compareTo(endCalendar) != 0) { ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar); startDayOfMonthBackground.setBackgroundColor( ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); TextView dayOfMonth = getDayOfMonthText(startCalendar); dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white)); } int totalDaysInMonth = auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); Calendar endDayOnMonthCalendar = Calendar.getInstance(locale); endDayOnMonthCalendar.setTime(auxCalendar.getTime()); endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth); if (endDayOnMonthCalendar.compareTo(endCalendar) < 0) { endCalendar = endDayOnMonthCalendar; ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar); endDayOfMonthBackground.setBackgroundColor( ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); TextView dayOfMonth = getDayOfMonthText(endCalendar); dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white)); } else { ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar); endDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_right); TextView dayOfMonth = getDayOfMonthText(endCalendar); dayOfMonth .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); ViewGroup dayOfMonthBackground = getDayOfMonthBackground(endCalendar); dayOfMonthBackground.setBackgroundResource(R.drawable.circle); } } else { int totalDaysInMonth = auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); Calendar endDayOnMonthCalendar = Calendar.getInstance(locale); endDayOnMonthCalendar.setTime(auxCalendar.getTime()); endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth); if (endDayOnMonthCalendar.compareTo(startCalendar) < 0) return; if (endDayOnMonthCalendar.compareTo(endCalendar) < 0) { endCalendar = endDayOnMonthCalendar; if (startCalendar.compareTo(endCalendar) != 0) { ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar); endDayOfMonthBackground.setBackgroundColor( ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); TextView dayOfMonth = getDayOfMonthText(endCalendar); dayOfMonth .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white)); } ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar); startDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_left); ViewGroup dayOfMonthBackground = getDayOfMonthBackground(startCalendar); dayOfMonthBackground.setBackgroundResource(R.drawable.circle); } else { int compare = startCalendar.compareTo(endCalendar);//compare startdate and enddate, if they are equal, just draw circle not draw background startdate and enddate ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar); if (compare != 0) startDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_left); ViewGroup dayOfMonthBackground = getDayOfMonthBackground(startCalendar); dayOfMonthBackground.setBackgroundResource(R.drawable.circle); ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar); if (compare != 0) endDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_right); dayOfMonthBackground = getDayOfMonthBackground(endCalendar); dayOfMonthBackground.setBackgroundResource(R.drawable.circle); TextView dayOfMonth = getDayOfMonthText(endCalendar); dayOfMonth .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); dayOfMonth = getDayOfMonthText(startCalendar); dayOfMonth .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); } } String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startCalendar.getTime()); int days = getDays(startCalendar, endCalendar); for (int i = 1; i < days; i++) { startCalendar.add(Calendar.DAY_OF_YEAR, 1); ViewGroup dayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar); TextView dayOfMonth = getDayOfMonthText(startCalendar); if (dayOfMonth.getVisibility() != View.VISIBLE) continue; dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white)); dayOfMonthBackground.setBackgroundColor( ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); } } else { if (startDay != null) { Calendar startDayOnMonthCalendar = Calendar.getInstance(locale); startDayOnMonthCalendar.setTime(currentCalendar.getTime()); startDayOnMonthCalendar.set(Calendar.DAY_OF_MONTH, 1); startDayOnMonthCalendar.set(Calendar.HOUR_OF_DAY, 0); startDayOnMonthCalendar.set(Calendar.MINUTE, 0); // set minute in hour startDayOnMonthCalendar.set(Calendar.SECOND, 0); // set second in minute startDayOnMonthCalendar.set(Calendar.MILLISECOND, 0); Calendar endDayOnMonthCalendar = Calendar.getInstance(locale); endDayOnMonthCalendar.setTime(startDayOnMonthCalendar.getTime()); int totalDaysInMonth = startDayOnMonthCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth); Calendar startCalendar = getCurrentCalendar(); startCalendar.setTime(startDay); if (startCalendar.compareTo(startDayOnMonthCalendar) >= 0 && startCalendar.compareTo(endDayOnMonthCalendar) <= 0) { selectStartDay(startDay); } } } }
From source file:org.apache.myfaces.examples.schedule.ScheduleExampleHandler.java
public void addSampleEntries(ActionEvent event) { if (model == null) return;// w ww .j a va 2s . c o m Calendar calendar = GregorianCalendar.getInstance(); calendar.setTime(model.getSelectedDate()); calendar.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); calendar.set(Calendar.HOUR_OF_DAY, 14); DefaultScheduleEntry entry1 = new DefaultScheduleEntry(); // every entry in a schedule must have a unique id entry1.setId(RandomStringUtils.randomNumeric(32)); entry1.setStartTime(calendar.getTime()); calendar.add(Calendar.MINUTE, 45); entry1.setEndTime(calendar.getTime()); entry1.setTitle("Test MyFaces schedule component"); entry1.setSubtitle("my office"); entry1.setDescription("We need to get this thing out of the sandbox ASAP"); model.addEntry(entry1); DefaultScheduleEntry entry2 = new DefaultScheduleEntry(); entry2.setId(RandomStringUtils.randomNumeric(32)); // entry2 overlaps entry1 calendar.add(Calendar.MINUTE, -20); entry2.setStartTime(calendar.getTime()); calendar.add(Calendar.HOUR, 2); entry2.setEndTime(calendar.getTime()); entry2.setTitle("Show schedule component to boss"); entry2.setSubtitle("my office"); entry2.setDescription("Convince him to get time to thoroughly test it"); model.addEntry(entry2); DefaultScheduleEntry entry3 = new DefaultScheduleEntry(); entry3.setId(RandomStringUtils.randomNumeric(32)); calendar.add(Calendar.DATE, 1); calendar.set(Calendar.HOUR_OF_DAY, 9); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); entry3.setStartTime(calendar.getTime()); calendar.set(Calendar.HOUR_OF_DAY, 17); entry3.setEndTime(calendar.getTime()); entry3.setTitle("Thoroughly test schedule component"); model.addEntry(entry3); DefaultScheduleEntry entry4 = new DefaultScheduleEntry(); entry4.setId(RandomStringUtils.randomNumeric(32)); calendar.add(Calendar.MONTH, -1); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); calendar.set(Calendar.HOUR_OF_DAY, 11); entry4.setStartTime(calendar.getTime()); calendar.set(Calendar.HOUR_OF_DAY, 14); entry4.setEndTime(calendar.getTime()); entry4.setTitle("Long lunch"); model.addEntry(entry4); DefaultScheduleEntry entry5 = new DefaultScheduleEntry(); entry5.setId(RandomStringUtils.randomNumeric(32)); calendar.add(Calendar.MONTH, 2); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR_OF_DAY, 1); entry5.setStartTime(calendar.getTime()); calendar.set(Calendar.HOUR_OF_DAY, 5); entry5.setEndTime(calendar.getTime()); entry5.setTitle("Fishing trip"); model.addEntry(entry5); //Let's add a zero length entry... DefaultScheduleEntry entry6 = new DefaultScheduleEntry(); calendar.setTime(model.getSelectedDate()); calendar.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); calendar.set(Calendar.HOUR_OF_DAY, 16); entry6.setId(RandomStringUtils.randomNumeric(32)); entry6.setStartTime(calendar.getTime()); entry6.setEndTime(calendar.getTime()); entry6.setTitle("Zero length entry"); entry6.setDescription("Is only rendered when the 'renderZeroLengthEntries' attribute is 'true'"); model.addEntry(entry6); //And also an allday event DefaultScheduleEntry entry7 = new DefaultScheduleEntry(); entry7.setId(RandomStringUtils.randomNumeric(32)); entry7.setTitle("All day event"); entry7.setSubtitle("This event renders as an all-day event"); entry7.setAllDay(true); model.addEntry(entry7); model.refresh(); }
From source file:org.apache.jsp.html.taglib.ui.calendar.page_jsp.java
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null;// w ww . j a v a 2 s. c om HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); // liferay-theme:defineObjects com.liferay.taglib.theme.DefineObjectsTag _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 = (com.liferay.taglib.theme.DefineObjectsTag) _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .get(com.liferay.taglib.theme.DefineObjectsTag.class); _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setPageContext(_jspx_page_context); _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setParent(null); int _jspx_eval_liferay_002dtheme_005fdefineObjects_005f0 = _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 .doStartTag(); if (_jspx_th_liferay_002dtheme_005fdefineObjects_005f0 .doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0); return; } _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0); com.liferay.portal.theme.ThemeDisplay themeDisplay = null; com.liferay.portal.model.Company company = null; com.liferay.portal.model.Account account = null; com.liferay.portal.model.User user = null; com.liferay.portal.model.User realUser = null; com.liferay.portal.model.Contact contact = null; com.liferay.portal.model.Layout layout = null; java.util.List layouts = null; java.lang.Long plid = null; com.liferay.portal.model.LayoutTypePortlet layoutTypePortlet = null; java.lang.Long scopeGroupId = null; com.liferay.portal.security.permission.PermissionChecker permissionChecker = null; java.util.Locale locale = null; java.util.TimeZone timeZone = null; com.liferay.portal.model.Theme theme = null; com.liferay.portal.model.ColorScheme colorScheme = null; com.liferay.portal.theme.PortletDisplay portletDisplay = null; java.lang.Long portletGroupId = null; themeDisplay = (com.liferay.portal.theme.ThemeDisplay) _jspx_page_context.findAttribute("themeDisplay"); company = (com.liferay.portal.model.Company) _jspx_page_context.findAttribute("company"); account = (com.liferay.portal.model.Account) _jspx_page_context.findAttribute("account"); user = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("user"); realUser = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("realUser"); contact = (com.liferay.portal.model.Contact) _jspx_page_context.findAttribute("contact"); layout = (com.liferay.portal.model.Layout) _jspx_page_context.findAttribute("layout"); layouts = (java.util.List) _jspx_page_context.findAttribute("layouts"); plid = (java.lang.Long) _jspx_page_context.findAttribute("plid"); layoutTypePortlet = (com.liferay.portal.model.LayoutTypePortlet) _jspx_page_context .findAttribute("layoutTypePortlet"); scopeGroupId = (java.lang.Long) _jspx_page_context.findAttribute("scopeGroupId"); permissionChecker = (com.liferay.portal.security.permission.PermissionChecker) _jspx_page_context .findAttribute("permissionChecker"); locale = (java.util.Locale) _jspx_page_context.findAttribute("locale"); timeZone = (java.util.TimeZone) _jspx_page_context.findAttribute("timeZone"); theme = (com.liferay.portal.model.Theme) _jspx_page_context.findAttribute("theme"); colorScheme = (com.liferay.portal.model.ColorScheme) _jspx_page_context.findAttribute("colorScheme"); portletDisplay = (com.liferay.portal.theme.PortletDisplay) _jspx_page_context .findAttribute("portletDisplay"); portletGroupId = (java.lang.Long) _jspx_page_context.findAttribute("portletGroupId"); out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); PortletRequest portletRequest = (PortletRequest) request .getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); PortletResponse portletResponse = (PortletResponse) request .getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE); String namespace = StringPool.BLANK; boolean useNamespace = GetterUtil.getBoolean((String) request.getAttribute("aui:form:useNamespace"), true); if ((portletResponse != null) && useNamespace) { namespace = portletResponse.getNamespace(); } String currentURL = PortalUtil.getCurrentURL(request); out.write('\n'); out.write('\n'); /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write('\n'); out.write('\n'); out.write('\n'); out.write('\n'); int month = GetterUtil.getInteger((String) request.getAttribute("liferay-ui:calendar:month")); int day = GetterUtil.getInteger((String) request.getAttribute("liferay-ui:calendar:day")); int year = GetterUtil.getInteger((String) request.getAttribute("liferay-ui:calendar:year")); String headerPattern = (String) request.getAttribute("liferay-ui:calendar:headerPattern"); Format headerFormat = (Format) request.getAttribute("liferay-ui:calendar:headerFormat"); Set data = (Set) request.getAttribute("liferay-ui:calendar:data"); boolean showAllPotentialWeeks = GetterUtil .getBoolean((String) request.getAttribute("liferay-ui:calendar:showAllPotentialWeeks")); Calendar selCal = CalendarFactoryUtil.getCalendar(timeZone, locale); selCal.set(Calendar.MONTH, month); selCal.set(Calendar.DATE, day); selCal.set(Calendar.YEAR, year); int selMonth = selCal.get(Calendar.MONTH); int selDay = selCal.get(Calendar.DATE); int selYear = selCal.get(Calendar.YEAR); int maxDayOfMonth = selCal.getActualMaximum(Calendar.DATE); selCal.set(Calendar.DATE, 1); int dayOfWeek = selCal.get(Calendar.DAY_OF_WEEK); selCal.set(Calendar.DATE, selDay); Calendar curCal = CalendarFactoryUtil.getCalendar(timeZone, locale); int curMonth = curCal.get(Calendar.MONTH); int curDay = curCal.get(Calendar.DATE); int curYear = curCal.get(Calendar.YEAR); Calendar prevCal = (Calendar) selCal.clone(); prevCal.add(Calendar.MONTH, -1); int maxDayOfPrevMonth = prevCal.getActualMaximum(Calendar.DATE); int weekNumber = 1; out.write("\n"); out.write("\n"); out.write("<div class=\"taglib-calendar\">\n"); out.write("\t<table class=\"lfr-table calendar-panel\">\n"); out.write("\n"); out.write("\t"); // c:if org.apache.taglibs.standard.tag.rt.core.IfTag _jspx_th_c_005fif_005f0 = (org.apache.taglibs.standard.tag.rt.core.IfTag) _005fjspx_005ftagPool_005fc_005fif_0026_005ftest .get(org.apache.taglibs.standard.tag.rt.core.IfTag.class); _jspx_th_c_005fif_005f0.setPageContext(_jspx_page_context); _jspx_th_c_005fif_005f0.setParent(null); // /html/taglib/ui/calendar/page.jsp(61,1) name = test type = boolean reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fif_005f0.setTest(Validator.isNotNull(headerPattern) || (headerFormat != null)); int _jspx_eval_c_005fif_005f0 = _jspx_th_c_005fif_005f0.doStartTag(); if (_jspx_eval_c_005fif_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("\n"); out.write("\n"); out.write("\t\t"); Format dateFormat = headerFormat; if (Validator.isNotNull(headerPattern)) { dateFormat = FastDateFormatFactoryUtil.getSimpleDateFormat(headerPattern, locale); } out.write("\n"); out.write("\n"); out.write("\t\t<tr class=\"calendar-header\">\n"); out.write("\t\t\t<th colspan=\"7\">\n"); out.write("\t\t\t\t"); out.print(dateFormat.format(selCal.getTime())); out.write("\n"); out.write("\t\t\t</th>\n"); out.write("\t\t</tr>\n"); out.write("\t"); int evalDoAfterBody = _jspx_th_c_005fif_005f0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_c_005fif_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f0); return; } _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f0); out.write("\n"); out.write("\n"); out.write("\t<tr class=\"portlet-section-header results-header\">\n"); out.write("\n"); out.write("\t\t"); for (int i = 0; i < 7; i++) { int daysIndex = (selCal.getFirstDayOfWeek() + i - 1) % 7; String className = StringPool.BLANK; if (i == 0) { className = "first"; } else if (i == 6) { className = "last"; } out.write("\n"); out.write("\n"); out.write("\t\t\t<th class=\""); out.print(className); out.write("\">\n"); out.write("\t\t\t\t"); out.print(LanguageUtil.get(pageContext, CalendarUtil.DAYS_ABBREVIATION[daysIndex])); out.write("\n"); out.write("\t\t\t</th>\n"); out.write("\n"); out.write("\t\t"); } out.write("\n"); out.write("\n"); out.write("\t</tr>\n"); out.write("\t<tr>\n"); out.write("\n"); out.write("\t\t"); if (((selCal.getFirstDayOfWeek()) == Calendar.MONDAY)) { if (dayOfWeek == 1) { dayOfWeek += 6; } else { dayOfWeek--; } } maxDayOfPrevMonth = (maxDayOfPrevMonth - dayOfWeek) + 1; for (int i = 1; i < dayOfWeek; i++) { String className = "calendar-inactive calendar-previous-month"; if (i == 1) { className += " first"; } else if (i == 7) { className += " last"; } out.write("\n"); out.write("\n"); out.write("\t\t\t<td class=\""); out.print(className); out.write('"'); out.write('>'); out.print(maxDayOfPrevMonth + i); out.write("</td>\n"); out.write("\n"); out.write("\t\t"); } for (int i = 1; i <= maxDayOfMonth; i++) { if (dayOfWeek > 7) { out.write("\n"); out.write("\n"); out.write("\t\t\t\t</tr>\n"); out.write("\t\t\t\t<tr>\n"); out.write("\n"); out.write("\t\t"); dayOfWeek = 1; weekNumber++; } Calendar tempCal = (Calendar) selCal.clone(); tempCal.set(Calendar.MONTH, selMonth); tempCal.set(Calendar.DATE, i); tempCal.set(Calendar.YEAR, selYear); boolean hasData = (data != null) && data.contains(new Integer(i)); String className = ""; if ((selMonth == curMonth) && (i == curDay) && (selYear == curYear)) { className = "calendar-current-day portlet-section-selected"; } if (hasData) { className += " has-events"; } if (dayOfWeek == 1) { className += " first"; } else if (dayOfWeek == 7) { className += " last"; } dayOfWeek++; out.write("\n"); out.write("\n"); out.write("\t\t\t<td class=\""); out.print(className); out.write("\">\n"); out.write("\t\t\t\t<a href=\"javascript:"); out.print(namespace); out.write("updateCalendar("); out.print(selMonth); out.write(','); out.write(' '); out.print(i); out.write(','); out.write(' '); out.print(selYear); out.write(");\"><span>"); out.print(i); out.write("</span></a>\n"); out.write("\t\t\t</td>\n"); out.write("\n"); out.write("\t\t"); } int dayOfNextMonth = 1; for (int i = 7; i >= dayOfWeek; i--) { String className = "calendar-inactive calendar-next-month"; if (dayOfWeek == 1) { className += " first"; } else if (i == dayOfWeek) { className += " last"; } out.write("\n"); out.write("\n"); out.write("\t\t\t<td class=\""); out.print(className); out.write('"'); out.write('>'); out.print(dayOfNextMonth++); out.write("</td>\n"); out.write("\n"); out.write("\t\t"); } if (showAllPotentialWeeks && weekNumber < 6) { out.write("\n"); out.write("\n"); out.write("\t\t\t<tr>\n"); out.write("\n"); out.write("\t\t\t\t"); for (int i = 1; i <= 7; i++) { String className = "calendar-inactive calendar-next-month"; if (i == 1) { className += " first"; } else if (i == 7) { className += " last"; } out.write("\n"); out.write("\n"); out.write("\t\t\t\t\t<td class=\""); out.print(className); out.write('"'); out.write('>'); out.print(dayOfNextMonth++); out.write("</td>\n"); out.write("\n"); out.write("\t\t\t\t"); } out.write("\n"); out.write("\n"); out.write("\t\t\t</tr>\n"); out.write("\n"); out.write("\t\t"); } out.write("\n"); out.write("\n"); out.write("\t</tr>\n"); out.write("\t</table>\n"); out.write("</div>"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
From source file:com.frameworkset.platform.sanylog.action.CounterController.java
/** * ?// w ww . ja v a 2 s . c o m * @param type week:7days:7month:30days:30 * @return String * @throws Exception */ @SuppressWarnings("rawtypes") public @ResponseBody String showBrowserCounterDayDistribute(int siteId, String type, String startTime, String endTime) throws Exception { String caption = "?"; String subCaption = ""; Calendar startDate = Calendar.getInstance(); Calendar endDate = Calendar.getInstance(); int addDay = 0; if ("week".equals(type)) { int offset = startDate.get(Calendar.DAY_OF_WEEK); startDate.add(Calendar.DAY_OF_MONTH, offset - (offset * 2 - 1)); endDate = (Calendar) startDate.clone(); endDate.add(Calendar.DAY_OF_MONTH, 6); addDay = 6; subCaption = ""; } else if ("7days".equals(type)) { startDate.add(Calendar.DAY_OF_MONTH, -6); addDay = 6; subCaption = "7"; } else if ("month".equals(type)) { int offset = startDate.get(Calendar.DAY_OF_MONTH); startDate.add(Calendar.DAY_OF_MONTH, offset - (offset * 2 - 1)); endDate = (Calendar) startDate.clone(); endDate.add(Calendar.MONTH, 1); endDate.add(Calendar.DAY_OF_MONTH, -1); addDay = startDate.getActualMaximum(Calendar.DAY_OF_MONTH) - startDate.getActualMinimum(Calendar.DAY_OF_MONTH); subCaption = ""; } else if ("30days".equals(type)) { startDate.add(Calendar.DAY_OF_MONTH, -29); addDay = 29; subCaption = "30"; } List<Calendar> calendarList = new ArrayList<Calendar>(); for (int i = 0; i <= addDay; i++) { Calendar tempStartDate = (Calendar) startDate.clone(); tempStartDate.add(Calendar.DAY_OF_MONTH, i); calendarList.add(tempStartDate); } if (StringUtil.isEmpty(startTime)) { startTime = DateUtils.format(startDate.getTime(), DateUtils.ISO8601_DATE_PATTERN); } if (StringUtil.isEmpty(endTime)) { endTime = DateUtils.format(endDate.getTime(), DateUtils.ISO8601_DATE_PATTERN); } List<HashMap> browserCounterDayDistribute = counterManager.getBrowserCounterDayDistribute(siteId, startTime, endTime); StringBuilder xml = new StringBuilder("<chart caption='").append(caption).append("' subCaption='") .append(subCaption) .append("' yMaxValue='100' bgColor='406181, 6DA5DB' bgAlpha='100' baseFontColor='FFFFFF' canvasBgAlpha='0' canvasBorderColor='FFFFFF' divLineColor='FFFFFF' divLineAlpha='100' numVDivlines='10' vDivLineisDashed='1' showAlternateVGridColor='1' lineColor='BBDA00' anchorRadius='4' anchorBgColor='BBDA00' anchorBorderColor='FFFFFF' anchorBorderThickness='2' showValues='0' toolTipBgColor='406181' toolTipBorderColor='406181' alternateHGridAlpha='5'>"); if (!CollectionUtils.isEmpty(browserCounterDayDistribute)) { for (Calendar calendar : calendarList) { int vday = calendar.get(Calendar.DAY_OF_MONTH); int vcount = 0; for (HashMap map : browserCounterDayDistribute) { if (vday == Integer.parseInt(map.get("VDAY").toString())) { vcount = Integer.parseInt(map.get("VCOUNT").toString()); break; } } xml.append("<set label='").append(vday).append("' value='").append(vcount).append("' />"); } xml.append( "<styles><definition><style name='LineShadow' type='shadow' color='333333' distance='6'/></definition><application><apply toObject='DATAPLOT' styles='LineShadow' /></application></styles></chart> "); } return xml.toString(); }