Example usage for java.util Calendar getActualMinimum

List of usage examples for java.util Calendar getActualMinimum

Introduction

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

Prototype

public int getActualMinimum(int field) 

Source Link

Document

Returns the minimum value that the specified calendar field could have, given the time value of this Calendar.

Usage

From source file:org.egov.mrs.application.reports.service.MarriageRegistrationReportsService.java

public Date getMonthStartday(final String monthyear) {
    Date monthStartDate = new Date();
    if (monthyear != null) {
        final String[] monthYear = monthyear.split("/");
        final Calendar calnew = Calendar.getInstance();
        calnew.set(Calendar.MONTH, Integer.parseInt(monthYear[0]) - 1);
        calnew.set(Calendar.YEAR, Integer.parseInt(monthYear[1]));
        calnew.set(Calendar.HOUR_OF_DAY, 0);
        calnew.set(Calendar.MINUTE, 0);
        calnew.set(Calendar.SECOND, 0);
        calnew.set(Calendar.DAY_OF_MONTH, calnew.getActualMinimum(Calendar.DAY_OF_MONTH));
        monthStartDate = calnew.getTime();

    }/*from   w  w  w. ja  va  2 s  . c  o m*/
    return monthStartDate;
}

From source file:com.proyecto.vista.MantenimientoInventario.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
    //        Periodo periodo = (Periodo) cmbPeriodo.getSelectedItem();
    Date inicio = jdateInicio.getDate();
    Date fin = jDateFin.getDate();

    Calendar cal = Calendar.getInstance();

    if (inicio == null) {
        cal.set(cal.get(Calendar.YEAR), cal.getActualMinimum(Calendar.MONTH),
                cal.getActualMinimum(Calendar.DAY_OF_MONTH));
        Date ini = cal.getTime();
        jdateInicio.setDate(ini);//  ww  w.j  av  a2  s  .  co m
    }
    if (fin == null) {
        cal.set(cal.get(Calendar.YEAR), cal.getActualMaximum(Calendar.MONTH),
                cal.getActualMaximum(Calendar.DAY_OF_MONTH));

        Date finals = cal.getTime();

        jDateFin.setDate(finals);
    }

    //        System.out.println("DATE 1: "+ jdateInicio.getDate());
    //        System.out.println("DATE 2: "+ jDateFin.getDate());
    paginaActual = 1;
    buscar();
    actualizarControlesNavegacion();
}

From source file:com.wso2telco.dep.reportingservice.northbound.NbHostObjectUtils.java

/**
 * Checks if is subscription valid for month.
 *
 * @param subAPI the sub api//from   w w  w  .  j a va  2s.co m
 * @param year the year
 * @param month the month
 * @return true, if is subscription valid for month
 * @throws Exception 
 */
private static boolean isSubscriptionValidForMonth(SubscribedAPI subAPI, String year, String month)
        throws Exception {
    BillingDAO billingDAO = new BillingDAO();
    java.util.Date createdTime = billingDAO.getSubscriptionCreatedTime(subAPI.getApplication().getId(),
            subAPI.getApiId());
    Date reportDate = Date.valueOf(year + "-" + month + "-01");
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(reportDate);

    // compare created time with 1st day of next month
    calendar.add(Calendar.MONTH, 1);
    calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
    if (createdTime != null) {
        return createdTime.before(calendar.getTime());
    } else {
        return false;
    }

}

From source file:com.wso2telco.dep.reportingservice.southbound.SbHostObjectUtils.java

/**
 * Checks if is subscription valid for month.
 *
 * @param subAPI the sub api/*from  w w w .  j  a v  a2  s .com*/
 * @param year the year
 * @param month the month
 * @return true, if is subscription valid for month
 * @throws APIManagementException the API management exception
 * @throws APIMgtUsageQueryServiceClientException the API mgt usage query service client exception
 * @throws BusinessException 
 */
private static boolean isSubscriptionValidForMonth(SubscribedAPI subAPI, String year, String month)
        throws BusinessException {
    BillingDAO billingDAO = new BillingDAO();
    java.util.Date createdTime;
    try {
        createdTime = billingDAO.getSubscriptionCreatedTime(subAPI.getApplication().getId(), subAPI.getApiId());
    } catch (Exception e) {
        throw new BusinessException(ReportingServiceError.INTERNAL_SERVER_ERROR);
    }
    Date reportDate = Date.valueOf(year + "-" + month + "-01");
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(reportDate);

    // compare created time with 1st day of next month
    calendar.add(Calendar.MONTH, 1);
    calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
    if (createdTime != null) {
        return createdTime.before(calendar.getTime());
    } else {
        return false;
    }

}

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

/**
 * ?//from w  ww. j a va 2s .  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();
}

From source file:CalendarUtils.java

private static void modify(Calendar val, int field, boolean round) {
    boolean roundUp = false;
    for (int i = 0; i < fields.length; i++) {
        for (int j = 0; j < fields[i].length; j++) {
            if (fields[i][j] == field) {
                //This is our field... we stop looping
                if (round && roundUp) {
                    if (field == CalendarUtils.SEMI_MONTH) {
                        //This is a special case that's hard to generalize
                        //If the date is 1, we round up to 16, otherwise
                        //  we subtract 15 days and add 1 month
                        if (val.get(Calendar.DATE) == 1) {
                            val.add(Calendar.DATE, 15);
                        } else {
                            val.add(Calendar.DATE, -15);
                            val.add(Calendar.MONTH, 1);
                        }/*w w  w .j  a  v  a 2  s . c o  m*/
                    } else {
                        //We need at add one to this field since the
                        //  last number causes us to round up
                        val.add(fields[i][0], 1);
                    }
                }
                return;
            }
        }
        //We have various fields that are not easy roundings
        int offset = 0;
        boolean offsetSet = false;
        //These are special types of fields that require different rounding rules
        switch (field) {
        case CalendarUtils.SEMI_MONTH:
            if (fields[i][0] == Calendar.DATE) {
                //If we're going to drop the DATE field's value,
                //  we want to do this our own way.
                //We need to subtrace 1 since the date has a minimum of 1
                offset = val.get(Calendar.DATE) - 1;
                //If we're above 15 days adjustment, that means we're in the
                //  bottom half of the month and should stay accordingly.
                if (offset >= 15) {
                    offset -= 15;
                }
                //Record whether we're in the top or bottom half of that range
                roundUp = offset > 7;
                offsetSet = true;
            }
            break;
        case Calendar.AM_PM:
            if (fields[i][0] == Calendar.HOUR) {
                //If we're going to drop the HOUR field's value,
                //  we want to do this our own way.
                offset = val.get(Calendar.HOUR);
                if (offset >= 12) {
                    offset -= 12;
                }
                roundUp = offset > 6;
                offsetSet = true;
            }
            break;
        }
        if (!offsetSet) {
            int min = val.getActualMinimum(fields[i][0]);
            int max = val.getActualMaximum(fields[i][0]);
            //Calculate the offset from the minimum allowed value
            offset = val.get(fields[i][0]) - min;
            //Set roundUp if this is more than half way between the minimum and maximum
            roundUp = offset > ((max - min) / 2);
        }
        //We need to remove this field
        val.add(fields[i][0], -offset);
    }
    throw new RuntimeException("We do not support that field.");

}

From source file:com.rr.wabshs.ui.surveys.surveyController.java

/**
 * @param filter START for start date of month e.g. Nov 01, 2013 END for end date of month e.g. Nov 30, 2013
 * @return//www  .ja v a2  s  .  c om
 */
public Date getMonthDate(String filter) {

    String MM_DD_YYYY = "yyyy-mm-dd";
    SimpleDateFormat sdf = new SimpleDateFormat(MM_DD_YYYY);
    sdf.setTimeZone(TimeZone.getTimeZone("EST"));
    sdf.format(GregorianCalendar.getInstance().getTime());

    Calendar cal = GregorianCalendar.getInstance();
    int date = cal.getActualMinimum(Calendar.DATE);
    if ("END".equalsIgnoreCase(filter)) {
        date = cal.getActualMaximum(Calendar.DATE);
        cal.set(Calendar.DATE, date);
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        cal.set(Calendar.MILLISECOND, 0);
    } else {
        cal.set(Calendar.DATE, date);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
    }

    return cal.getTime();
}

From source file:Main.java

/**
 * <p>Internal calculation method.</p>
 * /*from  w  w w  . j  a  v a 2  s  . c om*/
 * @param val  the calendar
 * @param field  the field constant
 * @param round  true to round, false to truncate
 * @throws ArithmeticException if the year is over 280 million
 */
private static void modify(Calendar val, int field, boolean round) {
    if (val.get(Calendar.YEAR) > 280000000) {
        throw new ArithmeticException("Calendar value too large for accurate calculations");
    }

    if (field == Calendar.MILLISECOND) {
        return;
    }

    // ----------------- Fix for LANG-59 ---------------------- START ---------------
    // see http://issues.apache.org/jira/browse/LANG-59
    //
    // Manually truncate milliseconds, seconds and minutes, rather than using
    // Calendar methods.

    Date date = val.getTime();
    long time = date.getTime();
    boolean done = false;

    // truncate milliseconds
    int millisecs = val.get(Calendar.MILLISECOND);
    if (!round || millisecs < 500) {
        time = time - millisecs;
    }
    if (field == Calendar.SECOND) {
        done = true;
    }

    // truncate seconds
    int seconds = val.get(Calendar.SECOND);
    if (!done && (!round || seconds < 30)) {
        time = time - (seconds * 1000L);
    }
    if (field == Calendar.MINUTE) {
        done = true;
    }

    // truncate minutes
    int minutes = val.get(Calendar.MINUTE);
    if (!done && (!round || minutes < 30)) {
        time = time - (minutes * 60000L);
    }

    // reset time
    if (date.getTime() != time) {
        date.setTime(time);
        val.setTime(date);
    }
    // ----------------- Fix for LANG-59 ----------------------- END ----------------

    boolean roundUp = false;
    for (int i = 0; i < fields.length; i++) {
        for (int j = 0; j < fields[i].length; j++) {
            if (fields[i][j] == field) {
                //This is our field... we stop looping
                if (round && roundUp) {
                    if (field == DateUtils.SEMI_MONTH) {
                        //This is a special case that's hard to generalize
                        //If the date is 1, we round up to 16, otherwise
                        //  we subtract 15 days and add 1 month
                        if (val.get(Calendar.DATE) == 1) {
                            val.add(Calendar.DATE, 15);
                        } else {
                            val.add(Calendar.DATE, -15);
                            val.add(Calendar.MONTH, 1);
                        }
                    } else {
                        //We need at add one to this field since the
                        //  last number causes us to round up
                        val.add(fields[i][0], 1);
                    }
                }
                return;
            }
        }
        //We have various fields that are not easy roundings
        int offset = 0;
        boolean offsetSet = false;
        //These are special types of fields that require different rounding rules
        switch (field) {
        case DateUtils.SEMI_MONTH:
            if (fields[i][0] == Calendar.DATE) {
                //If we're going to drop the DATE field's value,
                //  we want to do this our own way.
                //We need to subtrace 1 since the date has a minimum of 1
                offset = val.get(Calendar.DATE) - 1;
                //If we're above 15 days adjustment, that means we're in the
                //  bottom half of the month and should stay accordingly.
                if (offset >= 15) {
                    offset -= 15;
                }
                //Record whether we're in the top or bottom half of that range
                roundUp = offset > 7;
                offsetSet = true;
            }
            break;
        case Calendar.AM_PM:
            if (fields[i][0] == Calendar.HOUR_OF_DAY) {
                //If we're going to drop the HOUR field's value,
                //  we want to do this our own way.
                offset = val.get(Calendar.HOUR_OF_DAY);
                if (offset >= 12) {
                    offset -= 12;
                }
                roundUp = offset > 6;
                offsetSet = true;
            }
            break;
        }
        if (!offsetSet) {
            int min = val.getActualMinimum(fields[i][0]);
            int max = val.getActualMaximum(fields[i][0]);
            //Calculate the offset from the minimum allowed value
            offset = val.get(fields[i][0]) - min;
            //Set roundUp if this is more than half way between the minimum and maximum
            roundUp = offset > ((max - min) / 2);
        }
        //We need to remove this field
        if (offset != 0) {
            val.set(fields[i][0], val.get(fields[i][0]) - offset);
        }
    }
    throw new IllegalArgumentException("The field " + field + " is not supported");

}

From source file:com.silverpeas.scheduler.simple.SchedulerJob.java

/**
 * Generates a new timestamp/*from w w  w.  j ava2s . c  o  m*/
 * @return
 */
protected long getNextTimeStamp() {
    Calendar calcCalendar;
    long currentTime;
    boolean validTimeStamp;
    boolean carryMinute;
    boolean carryHour;
    boolean carryDayOfMonth;
    boolean carryMonth;
    boolean firstYearAccess;

    calcCalendar = Calendar.getInstance();

    SilverTrace.debug(MODULE_NAME, "SchedulerJob.getNextTimeStamp",
            "Current TimeStamp: " + logDateFormat.format(new Date(getMillisecondsOfCalendar(calcCalendar))));

    currentTime = getMillisecondsOfCalendar(calcCalendar);

    calcCalendar.set(Calendar.YEAR, currentYear);
    calcCalendar.set(Calendar.MONTH, currentMonth);
    calcCalendar.set(Calendar.DAY_OF_MONTH, currentDayOfMonth);
    calcCalendar.set(Calendar.HOUR_OF_DAY, currentHour);
    calcCalendar.set(Calendar.MINUTE, currentMinute);

    SilverTrace.debug(MODULE_NAME, "SchedulerJob.getNextTimeStamp",
            "Start TimeStamp: " + logDateFormat.format(new Date(getMillisecondsOfCalendar(calcCalendar))));

    // !!!!!! The values must be ordered ascend !!!!!
    validTimeStamp = false;
    carryMinute = false;
    carryHour = false;
    carryDayOfMonth = false;
    carryMonth = false;
    firstYearAccess = true;

    while (!validTimeStamp) {
        // Get new minute
        if (vMinutes.isEmpty()) {
            // Default ('*') -> Hit every minute
            // If the cron setting for minutes is *, we don't have to care about
            // incrementing minutes
            // So do a carryHour
            carryMinute = true;
        } else {
            // Special handling for lists with one element
            if (vMinutes.size() == 1) {
                currentMinute = vMinutes.get(0);
                carryMinute = !carryMinute;
                if (!carryMinute) {
                    carryHour = false;
                    carryDayOfMonth = false;
                    carryMonth = false;
                }
            } else {
                int indexOfMinutes = vMinutes.indexOf(currentMinute);
                if ((indexOfMinutes == -1) || (indexOfMinutes == (vMinutes.size() - 1))) {
                    currentMinute = vMinutes.get(0);
                    carryMinute = true;
                } else {
                    currentMinute = vMinutes.get(indexOfMinutes + 1);
                    carryMinute = false;
                    carryHour = false;
                    carryDayOfMonth = false;
                    carryMonth = false;
                }
            }
        }
        calcCalendar.set(Calendar.MINUTE, currentMinute);

        // Get new hour
        if (carryMinute) {
            if (vHours.isEmpty()) // Default ('*') -> Hit every hour
            {
                int maxHour = calcCalendar.getActualMaximum(Calendar.HOUR_OF_DAY);
                if (currentHour < maxHour) {
                    currentHour = currentHour + 1;
                    carryHour = false;
                    carryDayOfMonth = false;
                    carryMonth = false;
                } else {
                    currentHour = calcCalendar.getActualMinimum(Calendar.HOUR_OF_DAY);
                    carryHour = true;
                }
            } else {
                // Special handling for lists with one element
                if (vHours.size() == 1) {
                    currentHour = vHours.get(0);
                    carryHour = !carryHour;
                    if (!carryHour) {
                        carryDayOfMonth = false;
                        carryMonth = false;
                    }
                } else {
                    int indexOfHours = vHours.indexOf(currentHour);
                    if ((indexOfHours == -1) || (indexOfHours == (vHours.size() - 1))) {
                        currentHour = vHours.get(0);
                        carryHour = true;
                    } else {
                        currentHour = vHours.get(indexOfHours + 1);
                        carryHour = false;
                        carryDayOfMonth = false;
                        carryMonth = false;
                    }
                }
            }
            calcCalendar.set(Calendar.HOUR_OF_DAY, currentHour);
        }

        // Get new day of month
        if (carryHour) {
            if (vDaysOfMonth.isEmpty()) // Default ('*') -> Hit every month
            {
                int maxMonth = calcCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
                if (currentDayOfMonth < maxMonth) {
                    currentDayOfMonth = currentDayOfMonth + 1;
                    carryDayOfMonth = false;
                    carryMonth = false;
                } else {
                    currentDayOfMonth = calcCalendar.getActualMinimum(Calendar.DAY_OF_MONTH);
                    carryDayOfMonth = true;
                }
            } else {
                // Special handling for lists with one element
                if (vMinutes.size() == 1) {
                    currentDayOfMonth = vDaysOfMonth.get(0);
                    carryDayOfMonth = !carryDayOfMonth;
                    if (!carryDayOfMonth) {
                        carryMonth = false;
                    }
                } else {
                    int indexOfMonths = vDaysOfMonth.indexOf(currentDayOfMonth);
                    if ((indexOfMonths == -1) || (indexOfMonths == (vDaysOfMonth.size() - 1))) {
                        currentDayOfMonth = vDaysOfMonth.get(0);
                        carryDayOfMonth = true;
                    } else {
                        currentDayOfMonth = vDaysOfMonth.get(indexOfMonths + 1);
                        carryDayOfMonth = false;
                        carryMonth = false;
                    }
                }
            }
            calcCalendar.set(Calendar.DAY_OF_MONTH, currentDayOfMonth);
        }

        // Get new month
        if (carryDayOfMonth) {
            if (vMonths.isEmpty()) // Default ('*') -> Hit every month
            {
                int maxMonth = calcCalendar.getActualMaximum(Calendar.MONTH);
                if (currentMonth < maxMonth) {
                    currentMonth = currentMonth + 1;
                    carryMonth = false;
                } else {
                    currentMonth = calcCalendar.getActualMinimum(Calendar.MONTH);
                    carryMonth = true;
                }
            } else {
                // Special handling for lists with one element
                if (vMinutes.size() == 1) {
                    currentMonth = vMonths.get(0);
                    carryMonth = !carryMonth;
                } else {
                    int indexOfMonths = vMonths.indexOf(currentMonth);
                    if ((indexOfMonths == -1) || (indexOfMonths == (vMonths.size() - 1))) {
                        currentMonth = vMonths.get(0);
                        carryMonth = true;
                    } else {
                        currentMonth = vMonths.get(indexOfMonths + 1);
                        carryMonth = false;
                    }
                }
            }
            calcCalendar.set(Calendar.MONTH, currentMonth);
        }

        // Get new year
        if (carryMonth) {
            // Prevent Check for the 'ever carry' of one element lists
            if ((!firstYearAccess) || ((currentMinute == 0) && (currentHour == 0) && (currentDayOfMonth == 1)
                    && (currentMonth == 0))) {
                // Hit every year
                currentYear = currentYear + 1;
                calcCalendar.set(Calendar.YEAR, currentYear);
            }

            firstYearAccess = false;
        }

        // If time stamp is greater than the current time check the day of week
        if (getMillisecondsOfCalendar(calcCalendar) > currentTime) {
            // Check eventualy day movement while calculations
            if (calcCalendar.get(Calendar.DAY_OF_MONTH) == currentDayOfMonth) {
                // Check for correct day of week
                if (vDaysOfWeek.isEmpty()) {
                    validTimeStamp = true;
                } else {
                    for (Integer dayOfWeek : vDaysOfWeek) {
                        if (calcCalendar.get(Calendar.DAY_OF_WEEK) == dayOfWeek) {
                            validTimeStamp = true;
                            break;
                        }
                    }
                }
            }
        }
    } // while (getMillisecondsOfCurrentTimeStamp (calcCalendar) < currentTime)

    SilverTrace.debug(MODULE_NAME, "SchedulerJob.getNextTimeStamp",
            "New TimeStamp: " + logDateFormat.format(new Date(getMillisecondsOfCalendar(calcCalendar))));
    return getMillisecondsOfCalendar(calcCalendar);
}

From source file:org.alfresco.solr.query.Solr4QueryParser.java

/**
  * @param dateAndResolution//ww  w.ja  va 2 s  .  com
  * @return
 */
private String getDateStart(Pair<Date, Integer> dateAndResolution) {
    Calendar cal = Calendar.getInstance(I18NUtil.getLocale());
    cal.setTime(dateAndResolution.getFirst());
    switch (dateAndResolution.getSecond()) {
    case Calendar.YEAR:
        cal.set(Calendar.MONTH, cal.getActualMinimum(Calendar.MONTH));
    case Calendar.MONTH:
        cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
    case Calendar.DAY_OF_MONTH:
        cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY));
    case Calendar.HOUR_OF_DAY:
        cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE));
    case Calendar.MINUTE:
        cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND));
    case Calendar.SECOND:
        cal.set(Calendar.MILLISECOND, cal.getActualMinimum(Calendar.MILLISECOND));
    case Calendar.MILLISECOND:
    default:
    }
    SimpleDateFormat formatter = CachingDateFormat.getSolrDatetimeFormat();
    formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
    return formatter.format(cal.getTime());
}