Example usage for java.util Calendar clone

List of usage examples for java.util Calendar clone

Introduction

In this page you can find the example usage for java.util Calendar clone.

Prototype

@Override
public Object clone() 

Source Link

Document

Creates and returns a copy of this object.

Usage

From source file:tw.edu.chit.struts.action.language.ReportPrintAction.java

/**
 * //from  w w w  .jav  a 2 s.  co m
 * 
 * @param mapping org.apache.struts.action.ActionMapping object
 * @param form org.apache.struts.action.ActionForm object
 * @param request request javax.servlet.http.HttpServletRequest object
 * @param response response javax.servlet.http.HttpServletResponse object
 * @param sterm 
 */
@SuppressWarnings("unchecked")
private void printDeptStdSkillList1(ActionMapping mapping, DynaActionForm form, HttpServletRequest request,
        HttpServletResponse response, String sterm) throws Exception {

    HttpSession session = request.getSession(false);
    AdminManager am = (AdminManager) getBean(IConstants.ADMIN_MANAGER_BEAN_NAME);
    MemberManager mm = (MemberManager) getBean(MEMBER_MANAGER_BEAN_NAME);

    Member member = (Member) getUserCredential(session).getMember();
    Empl empl = mm.findEmplByOid(member.getOid());
    ServletContext context = request.getSession().getServletContext();

    DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
    Calendar cal = Calendar.getInstance();
    Calendar cal1 = (Calendar) cal.clone();
    Calendar cal2 = (Calendar) cal.clone();
    if (StringUtils.isNotBlank(form.getString("licenseValidDateStart"))
            || StringUtils.isNotBlank(form.getString("licenseValidDateEnd"))) {
        Date from = StringUtils.isBlank(form.getString("licenseValidDateStart")) ? null
                : Toolket.parseNativeDate(form.getString("licenseValidDateStart"));
        // ???
        Date to = StringUtils.isBlank(form.getString("licenseValidDateEnd")) ? Calendar.getInstance().getTime()
                : Toolket.parseNativeDate(form.getString("licenseValidDateEnd"));

        cal1.setTime(from);
        cal1.set(Calendar.HOUR_OF_DAY, 0);
        cal1.set(Calendar.MINUTE, 0);
        cal1.set(Calendar.SECOND, 0);
        cal1.set(Calendar.MILLISECOND, 0);

        cal2.setTime(to);
        cal2.set(Calendar.HOUR_OF_DAY, 23);
        cal2.set(Calendar.MINUTE, 59);
        cal2.set(Calendar.SECOND, 59);
        cal2.set(Calendar.MILLISECOND, 999);
    }

    String hql = "SELECT count(*), s FROM StdSkill s WHERE s.deptNo = ? "
            + "AND s.licenseValidDate BETWEEN ? AND ? " + "GROUP BY s.licenseCode";

    List<Object> ret = (List<Object>) am.find(hql, new Object[] { "0", cal1.getTime(), cal2.getTime() }); // 

    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet sheet = workbook.createSheet("");
    sheet.setColumnWidth(0, 1500);
    sheet.setColumnWidth(1, 10000);
    sheet.setColumnWidth(2, 3000);
    sheet.setColumnWidth(3, 3000);
    sheet.setColumnWidth(4, 8000);
    sheet.setColumnWidth(5, 1800);
    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 5));

    HSSFFont fontSize12 = workbook.createFont();
    fontSize12.setFontHeightInPoints((short) 12);
    fontSize12.setFontName("Arial Unicode MS");

    HSSFFont fontSize10 = workbook.createFont();
    fontSize10.setFontHeightInPoints((short) 10);
    fontSize10.setFontName("Arial Unicode MS");

    // Header
    Toolket.setCellValue(workbook, sheet, 0, 0,
            "?" + Toolket.getEmpUnit(empl.getUnit()) + "  ("
                    + df.format(cal1.getTime()) + "~" + df.format(cal2.getTime()) + ")",
            fontSize12, HSSFCellStyle.ALIGN_CENTER, false, 35.0F, null);

    // Column Header
    Toolket.setCellValue(workbook, sheet, 1, 0, "?", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null);
    Toolket.setCellValue(workbook, sheet, 1, 1, "??", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
            null);
    Toolket.setCellValue(workbook, sheet, 1, 2, "/", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
            null);
    Toolket.setCellValue(workbook, sheet, 1, 3, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
            null);
    Toolket.setCellValue(workbook, sheet, 1, 4, "?", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
            null);
    Toolket.setCellValue(workbook, sheet, 1, 5, "?", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null);
    int index = 2, totals = 0;
    StdSkill skill = null;
    List<LicenseCode> codes = null;
    List<LicenseCode961> code961s = null;
    LicenseCode code = null;
    LicenseCode961 code961 = null;
    Object[] data = null;

    for (Object o : ret) {

        data = (Object[]) o;
        totals += (Integer) data[0];
        skill = (StdSkill) data[1];

        Toolket.setCellValue(workbook, sheet, index, 0, String.valueOf(index - 1), fontSize10,
                HSSFCellStyle.ALIGN_CENTER, true, null);
        Toolket.setCellValue(workbook, sheet, index, 5, ((Integer) data[0]).toString(), fontSize10,
                HSSFCellStyle.ALIGN_CENTER, true, null);

        codes = (List<LicenseCode>) am
                .findLicenseCodesBy(new LicenseCode(Integer.valueOf(skill.getLicenseCode())));

        if (!codes.isEmpty()) {
            code = codes.get(0);
            Toolket.setCellValue(workbook, sheet, index, 1, code.getName(), fontSize10,
                    HSSFCellStyle.ALIGN_LEFT, true, null);
            Toolket.setCellValue(workbook, sheet, index, 2, code.getLevel(), fontSize10,
                    HSSFCellStyle.ALIGN_CENTER, true, null);
            Toolket.setCellValue(workbook, sheet, index, 3, code.getType().toString(), fontSize10,
                    HSSFCellStyle.ALIGN_CENTER, true, null);
            Toolket.setCellValue(workbook, sheet, index, 4, code.getDeptName(), fontSize10,
                    HSSFCellStyle.ALIGN_LEFT, true, null);
        } else {
            code961s = (List<LicenseCode961>) am
                    .findLicenseCode961sBy(new LicenseCode961(Integer.valueOf(skill.getLicenseCode())));
            if (!code961s.isEmpty()) {
                code961 = code961s.get(0);
                Toolket.setCellValue(workbook, sheet, index, 1, code961.getName(), fontSize10,
                        HSSFCellStyle.ALIGN_LEFT, true, null);
                Toolket.setCellValue(workbook, sheet, index, 2, code961.getLevel(), fontSize10,
                        HSSFCellStyle.ALIGN_CENTER, true, null);
                Toolket.setCellValue(workbook, sheet, index, 3, code961.getType().toString(), fontSize10,
                        HSSFCellStyle.ALIGN_CENTER, true, null);
                Toolket.setCellValue(workbook, sheet, index, 4, code961.getDeptName(), fontSize10,
                        HSSFCellStyle.ALIGN_LEFT, true, null);
            }
        }

        index++;
    }

    sheet.addMergedRegion(new CellRangeAddress(index, index, 0, 4));
    Toolket.setCellValue(workbook, sheet, index, 0, "?", fontSize12, HSSFCellStyle.ALIGN_CENTER, false,
            35.0F, null);
    Toolket.setCellValue(workbook, sheet, index, 5, String.valueOf(totals), fontSize12,
            HSSFCellStyle.ALIGN_CENTER, false, 35.0F, null);

    File tempDir = new File(
            context.getRealPath("/WEB-INF/reports/temp/" + getUserCredential(session).getMember().getIdno()
                    + (new SimpleDateFormat("yyyyMMdd").format(new Date()))));
    if (!tempDir.exists())
        tempDir.mkdirs();

    File output = new File(tempDir, "DeptStdSkillList1.xls");
    FileOutputStream fos = new FileOutputStream(output);
    workbook.write(fos);
    fos.close();

    JasperReportUtils.printXlsToFrontEnd(response, output);
    output.delete();
    tempDir.delete();
}

From source file:tw.edu.chit.struts.action.language.ReportPrintAction.java

/**
 * ?//from w w w.ja v  a  2 s .c  om
 * 
 * @param mapping org.apache.struts.action.ActionMapping object
 * @param form org.apache.struts.action.ActionForm object
 * @param request request javax.servlet.http.HttpServletRequest object
 * @param response response javax.servlet.http.HttpServletResponse object
 * @param sterm 
 */
@SuppressWarnings("unchecked")
private void printDeptStdSkillList5(ActionMapping mapping, DynaActionForm form, HttpServletRequest request,
        HttpServletResponse response, String sterm) throws Exception {

    HttpSession session = request.getSession(false);
    AdminManager am = (AdminManager) getBean(IConstants.ADMIN_MANAGER_BEAN_NAME);
    MemberManager mm = (MemberManager) getBean(MEMBER_MANAGER_BEAN_NAME);

    Member member = (Member) getUserCredential(session).getMember();
    Empl empl = mm.findEmplByOid(member.getOid());
    ServletContext context = request.getSession().getServletContext();

    DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
    Calendar cal = Calendar.getInstance();
    Calendar cal1 = (Calendar) cal.clone();
    Calendar cal2 = (Calendar) cal.clone();
    if (StringUtils.isNotBlank(form.getString("licenseValidDateStart"))
            || StringUtils.isNotBlank(form.getString("licenseValidDateEnd"))) {
        Date from = StringUtils.isBlank(form.getString("licenseValidDateStart")) ? null
                : Toolket.parseNativeDate(form.getString("licenseValidDateStart"));
        // ???
        Date to = StringUtils.isBlank(form.getString("licenseValidDateEnd")) ? Calendar.getInstance().getTime()
                : Toolket.parseNativeDate(form.getString("licenseValidDateEnd"));

        cal1.setTime(from);
        cal1.set(Calendar.HOUR_OF_DAY, 0);
        cal1.set(Calendar.MINUTE, 0);
        cal1.set(Calendar.SECOND, 0);
        cal1.set(Calendar.MILLISECOND, 0);

        cal2.setTime(to);
        cal2.set(Calendar.HOUR_OF_DAY, 23);
        cal2.set(Calendar.MINUTE, 59);
        cal2.set(Calendar.SECOND, 59);
        cal2.set(Calendar.MILLISECOND, 999);
    }

    String hql = "SELECT COUNT(*), s.techIdno, s.licenseCode FROM StdSkill s "
            + "WHERE s.deptNo = ? AND s.techIdno IS NOT NULL " + "AND s.licenseValidDate BETWEEN ? AND ? "
            + "GROUP BY s.techIdno, s.licenseCode";

    List<Object> ret = (List<Object>) am.find(hql, new Object[] { "0", cal1.getTime(), cal2.getTime() }); // 

    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet sheet = workbook.createSheet("?");
    sheet.setColumnWidth(0, 4000);
    sheet.setColumnWidth(1, 6000);
    sheet.setColumnWidth(2, 4000);
    sheet.setColumnWidth(3, 3000);
    sheet.setColumnWidth(4, 4000);
    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 4));

    HSSFFont fontSize12 = workbook.createFont();
    fontSize12.setFontHeightInPoints((short) 12);
    fontSize12.setFontName("Arial Unicode MS");

    HSSFFont fontSize10 = workbook.createFont();
    fontSize10.setFontHeightInPoints((short) 10);
    fontSize10.setFontName("Arial Unicode MS");

    // Header
    Toolket.setCellValue(workbook, sheet, 0, 0,
            "?" + Toolket.getEmpUnit(empl.getUnit())
                    + "? (" + df.format(cal1.getTime()) + "~"
                    + df.format(cal2.getTime()) + ")",
            fontSize12, HSSFCellStyle.ALIGN_CENTER, false, 35.0F, null);

    // Column Header
    Toolket.setCellValue(workbook, sheet, 1, 0, "", fontSize10, HSSFCellStyle.ALIGN_CENTER,
            true, null);
    Toolket.setCellValue(workbook, sheet, 1, 1, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
            null);
    Toolket.setCellValue(workbook, sheet, 1, 2, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null);
    Toolket.setCellValue(workbook, sheet, 1, 3, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
            null);
    Toolket.setCellValue(workbook, sheet, 1, 4, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null);

    int index = 2;
    Object[] data = null;
    DEmpl dempl = null;

    for (Object o : ret) {

        data = (Object[]) o;

        sheet.addMergedRegion(new CellRangeAddress(index, index + 2, 0, 0));
        empl = mm.findEmplByIdno((String) data[1]);
        if (empl == null) {
            dempl = mm.findDEmplByIdno((String) data[1]);
            Toolket.setCellValue(workbook, sheet, index, 0, dempl.getCname(), fontSize10,
                    HSSFCellStyle.ALIGN_CENTER, true, null);
        } else {
            Toolket.setCellValue(workbook, sheet, index, 0, empl.getCname(), fontSize10,
                    HSSFCellStyle.ALIGN_CENTER, true, null);
        }

        Toolket.setCellValue(workbook, sheet, index + 1, 0, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
                null);
        Toolket.setCellValue(workbook, sheet, index + 2, 0, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
                null);

        Toolket.setCellValue(workbook, sheet, index, 1, "", fontSize10,
                HSSFCellStyle.ALIGN_CENTER, true, null);
        Toolket.setCellValue(workbook, sheet, index + 1, 1, "", fontSize10,
                HSSFCellStyle.ALIGN_CENTER, true, null);
        Toolket.setCellValue(workbook, sheet, index + 2, 1, "", fontSize10,
                HSSFCellStyle.ALIGN_CENTER, true, null);

        Toolket.setCellValue(workbook, sheet, index, 2, "10", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
                null);
        Toolket.setCellValue(workbook, sheet, index + 1, 2, "5", fontSize10, HSSFCellStyle.ALIGN_CENTER,
                true, null);
        Toolket.setCellValue(workbook, sheet, index + 2, 2, "2", fontSize10, HSSFCellStyle.ALIGN_CENTER,
                true, null);

        Toolket.setCellValue(workbook, sheet, index, 3, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null);
        Toolket.setCellValue(workbook, sheet, index + 1, 3, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
                null);
        Toolket.setCellValue(workbook, sheet, index + 2, 3, ((Integer) data[0]).toString(), fontSize10,
                HSSFCellStyle.ALIGN_CENTER, true, null);

        Toolket.setCellValue(workbook, sheet, index, 4, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null);
        Toolket.setCellValue(workbook, sheet, index + 1, 4, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
                null);
        Toolket.setCellValue(workbook, sheet, index + 2, 4, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true,
                null);

        index += 3;
    }

    index++;
    sheet.addMergedRegion(new CellRangeAddress(index, index, 0, 1));
    Toolket.setCellValue(workbook, sheet, index, 0, " : ?20", fontSize10,
            HSSFCellStyle.ALIGN_LEFT, false, null);
    File tempDir = new File(
            context.getRealPath("/WEB-INF/reports/temp/" + getUserCredential(session).getMember().getIdno()
                    + (new SimpleDateFormat("yyyyMMdd").format(new Date()))));
    if (!tempDir.exists())
        tempDir.mkdirs();

    File output = new File(tempDir, "DeptStdSkillList5.xls");
    FileOutputStream fos = new FileOutputStream(output);
    workbook.write(fos);
    fos.close();

    JasperReportUtils.printXlsToFrontEnd(response, output);
    output.delete();
    tempDir.delete();
}

From source file:com.frameworkset.platform.sanylog.action.CounterController.java

/**
 * ? /*from  w  w  w. j a  va  2  s  . com*/
 * @param type week:7days:7month:30days:30
 * @return String 
 * @throws Exception
 */
@SuppressWarnings("rawtypes")
public @ResponseBody String showBrowserTypeDayDistribute(int siteId, String type, String startTime,
        String endTime) throws Exception {

    String caption = "?";
    String subCaption = "";

    Calendar startDate = Calendar.getInstance();
    Calendar endDate = Calendar.getInstance();

    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);

        subCaption = "";
    } else if ("7days".equals(type)) {
        startDate.add(Calendar.DAY_OF_MONTH, -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);

        subCaption = "";
    } else if ("30days".equals(type)) {
        startDate.add(Calendar.DAY_OF_MONTH, -30);

        subCaption = "30";
    }

    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> browserTypeDayDistribute = counterManager.getBrowserTypeDayDistribute(siteId, startTime,
            endTime);

    StringBuilder xml = new StringBuilder("<chart caption='").append(caption).append("' subCaption='")
            .append(subCaption)
            .append("' showLabels='0' showValues='0' showLegend='1'  legendPosition='RIGHT' chartrightmargin='40' bgcolor='ECF5FF' bgalpha='70' bordercolor='C6D2DF' basefontcolor='2F2F2F' basefontsize='11' showpercentvalues='1' bgratio='0' startingangle='200' animation='1'>");

    if (!CollectionUtils.isEmpty(browserTypeDayDistribute)) {
        for (HashMap map : browserTypeDayDistribute) {
            int vcount = Integer.parseInt(map.get("VCOUNT").toString());
            String browserType = map.get("VBROWSERTYPE").toString();
            System.out.println();
            xml.append(" <set value='").append(vcount).append("' label='").append(browserType).append("'/>");
        }
    }

    xml.append(" </chart>");
    // System.out.println("xml--------------------------------"+xml.toString());
    return xml.toString();
}

From source file:com.frameworkset.platform.sanylog.action.CounterController.java

/**
 * ?IP? //from   ww  w  . j a v a 2s  .c  o  m
 * @param type week:7days:7month:30days:30
 * @return String 
 * @throws Exception
 */
@SuppressWarnings("rawtypes")
public @ResponseBody String showBrowserIPDayDistribute(int siteId, String type, String startTime,
        String endTime) throws Exception {

    String caption = "?IP?";
    String subCaption = "";

    Calendar startDate = Calendar.getInstance();
    Calendar endDate = Calendar.getInstance();

    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);

        subCaption = "";
    } else if ("7days".equals(type)) {
        startDate.add(Calendar.DAY_OF_MONTH, -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);

        subCaption = "";
    } else if ("30days".equals(type)) {
        startDate.add(Calendar.DAY_OF_MONTH, -30);

        subCaption = "30";
    }

    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> browserIPDayDistribute = counterManager.getBrowserIPDayDistribute(siteId, startTime, endTime);

    StringBuilder xml = new StringBuilder("<chart caption='").append(caption).append("' subCaption='")
            .append(subCaption)
            .append("' showLabels='0' showValues='0' showLegend='1'  legendPosition='RIGHT' chartrightmargin='40' bgcolor='ECF5FF' bgalpha='70' bordercolor='C6D2DF' basefontcolor='2F2F2F' basefontsize='11' showpercentvalues='1' bgratio='0' startingangle='200' animation='1'>");

    if (!CollectionUtils.isEmpty(browserIPDayDistribute)) {
        for (HashMap map : browserIPDayDistribute) {
            int vcount = Integer.parseInt(map.get("VCOUNT").toString());
            String browserType = map.get("VBROWSERIP").toString();

            xml.append(" <set value='").append(vcount).append("' label='").append(browserType).append(".**")
                    .append("'/>");
        }
    }

    xml.append(" </chart>");

    return xml.toString();
}

From source file:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java

private DefaultCategoryDataset getActivityWeekBarDataSet(String siteId) {
    //      LOG.info("Generating activityWeekBarDataSet");
    SummaryActivityChartData sac = M_sm.getSummaryActivityChartData(siteId, StatsManager.VIEW_WEEK,
            StatsManager.CHARTTYPE_BAR);
    if (sac == null)
        return null;
    DefaultCategoryDataset activityWeekBarDataSet = new DefaultCategoryDataset();
    String activity = msgs.getString("legend_activity");

    Calendar cal = Calendar.getInstance();
    cal.setTime(sac.getFirstDay());//from  w w  w  .  j a va 2 s.c  om
    Calendar currDay = (Calendar) cal.clone();

    long activityData[] = sac.getActivity();
    for (int i = 0; i < activityData.length; i++) {
        activityWeekBarDataSet.addValue(activityData[i], activity,
                getWeekDaysMap().get(currDay.get(Calendar.DAY_OF_WEEK)));
        currDay.add(Calendar.DAY_OF_YEAR, 1);
    }
    return activityWeekBarDataSet;
}

From source file:com.alkacon.opencms.calendar.CmsCalendarDisplay.java

/**
 * Returns all displayed days of the specified week with their corresponding entries as lists.<p>
 * /*from ww  w . j ava2s  .c  om*/
 * The key of the Map has to be a Date object.<p>
 * 
 * The Map values are always lists of {@link CmsCalendarEntry} objects, if no entries are available for a specific day,
 * an empty List is returned.<p>
 * 
 * @param year the year of the month to display
 * @param week the week of the year to display
 * @return all displayed days of the specified day range with their corresponding entries as lists
 */
public Map getEntriesForWeek(int year, int week) {

    Calendar startDay = new GregorianCalendar(getJsp().getRequestContext().getLocale());
    startDay.set(Calendar.YEAR, year);
    startDay.set(Calendar.WEEK_OF_YEAR, week);
    startDay.set(Calendar.DAY_OF_WEEK, startDay.getFirstDayOfWeek());

    Calendar endDay = (Calendar) startDay.clone();
    endDay.add(Calendar.DAY_OF_YEAR, 6);

    return getEntriesForDays(startDay, endDay);
}

From source file:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java

private DefaultCategoryDataset getVisitsWeekDataSet(String siteId) {
    //      LOG.info("Generating visitsWeekDataSet");
    SummaryVisitsChartData svc = M_sm.getSummaryVisitsChartData(siteId, StatsManager.VIEW_WEEK);
    if (svc == null)
        return null;
    DefaultCategoryDataset visitsWeekDataSet = new DefaultCategoryDataset();
    String visits = msgs.getString("legend_visits");
    String uniqueVisits = msgs.getString("legend_unique_visitors");

    Calendar cal = Calendar.getInstance();
    cal.setTime(svc.getFirstDay());//from  ww  w  .  j a v  a 2 s. c  o m
    Calendar currDay = (Calendar) cal.clone();

    long visitsData[] = svc.getVisits();
    long uniqueVisitsData[] = svc.getUniqueVisits();
    for (int i = 0; i < visitsData.length; i++) {
        visitsWeekDataSet.addValue(visitsData[i], visits,
                getWeekDaysMap().get(currDay.get(Calendar.DAY_OF_WEEK)));
        visitsWeekDataSet.addValue(uniqueVisitsData[i], uniqueVisits,
                getWeekDaysMap().get(currDay.get(Calendar.DAY_OF_WEEK)));
        currDay.add(Calendar.DAY_OF_YEAR, 1);
    }
    return visitsWeekDataSet;
}

From source file:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java

private DefaultCategoryDataset getActivityYearBarDataSet(String siteId) {
    //      LOG.info("Generating activityYearBarDataSet");
    SummaryActivityChartData sac = M_sm.getSummaryActivityChartData(siteId, StatsManager.VIEW_YEAR,
            StatsManager.CHARTTYPE_BAR);
    if (sac == null)
        return null;
    DefaultCategoryDataset activityYearBarDataSet = new DefaultCategoryDataset();
    String activity = msgs.getString("legend_activity");

    Calendar cal = Calendar.getInstance();
    cal.setTime(sac.getFirstDay());/*  ww  w  . ja v  a 2s . c  o  m*/
    Calendar currMonth = (Calendar) cal.clone();

    long activityData[] = sac.getActivity();
    for (int i = 0; i < activityData.length; i++) {
        activityYearBarDataSet.addValue(activityData[i], activity,
                getMonthNamesMap().get(currMonth.get(Calendar.MONTH)));
        currMonth.add(Calendar.MONTH, 1);
    }

    return activityYearBarDataSet;
}

From source file:org.kuali.kfs.module.ld.batch.service.impl.LaborScrubberProcess.java

protected boolean isCurrentDateBeforeCutoff(Calendar currentCal) {
    if (cutoffHour != null && cutoffMinute != null && cutoffSecond != null) {
        // if cutoff date is not properly defined
        // 24 hour clock (i.e. hour is 0 - 23)

        // clone the calendar so we get the same month, day, year
        // then change the hour, minute, second fields
        // then see if the cutoff is before or after
        Calendar cutoffTime = (Calendar) currentCal.clone();
        cutoffTime.setLenient(false);/*from w w w  .  ja v  a  2  s .  c o m*/
        cutoffTime.set(Calendar.HOUR_OF_DAY, cutoffHour);
        cutoffTime.set(Calendar.MINUTE, cutoffMinute);
        cutoffTime.set(Calendar.SECOND, cutoffSecond);
        cutoffTime.set(Calendar.MILLISECOND, 0);

        return currentCal.before(cutoffTime);
    }
    // if cutoff date is not properly defined, then it is considered to be after the cutoff
    return false;
}

From source file:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java

private DefaultCategoryDataset getVisitsYearDataSet(String siteId) {
    //      LOG.info("Generating visitsYearDataSet");
    SummaryVisitsChartData svc = M_sm.getSummaryVisitsChartData(siteId, StatsManager.VIEW_YEAR);
    if (svc == null)
        return null;
    DefaultCategoryDataset visitsYearDataSet = new DefaultCategoryDataset();
    String visits = msgs.getString("legend_visits");
    String uniqueVisits = msgs.getString("legend_unique_visitors");

    Calendar cal = Calendar.getInstance();
    cal.setTime(svc.getFirstDay());/*  w w  w .ja v a  2s . c o  m*/
    Calendar currMonth = (Calendar) cal.clone();

    long visitsData[] = svc.getVisits();
    long uniqueVisitsData[] = svc.getUniqueVisits();
    for (int i = 0; i < visitsData.length; i++) {
        visitsYearDataSet.addValue(visitsData[i], visits,
                getMonthNamesMap().get(currMonth.get(Calendar.MONTH)));
        visitsYearDataSet.addValue(uniqueVisitsData[i], uniqueVisits,
                getMonthNamesMap().get(currMonth.get(Calendar.MONTH)));
        currMonth.add(Calendar.MONTH, 1);
    }
    return visitsYearDataSet;
}