List of usage examples for java.util Calendar getActualMinimum
public int getActualMinimum(int field)
Calendar
. From source file:org.wso2.carbon.identity.account.suspension.notification.task.NotificationReceiversRetrievalManager.java
private static Calendar getCurrentExecutionTime(Date triggerTime) { Calendar tr = Calendar.getInstance(); tr.setTime(triggerTime);/*from w w w. java 2 s. c om*/ Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, tr.get(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, tr.get(Calendar.MINUTE)); calendar.set(Calendar.SECOND, tr.get(Calendar.SECOND)); calendar.set(Calendar.MILLISECOND, calendar.getActualMinimum(Calendar.MILLISECOND)); return calendar; }
From source file:gov.nih.nci.cabig.caaers.utils.DateUtils.java
/** * Will return the date representing the first day of this month * @param currDate//from w w w . j av a 2s.co m * @return */ public static Date firstDayOfThisMonth(Date currDate) { Calendar c = Calendar.getInstance(); c.setTime(currDate); c.set(Calendar.DAY_OF_MONTH, c.getActualMinimum(Calendar.DAY_OF_MONTH)); return c.getTime(); }
From source file:io.horizondb.model.core.util.TimeUtils.java
/** * Truncate this date, leaving the field specified as the most significant field. * /*w ww . j a v a 2 s . co m*/ * @param calendar the calendar to truncate * @param field the most significant field */ public static void truncate(Calendar calendar, int field) { Validate.isTrue(ArrayUtils.contains(TRUNCATING_FIELDS, field), "the specified field cannot be used to truncate the specified calendar"); for (int calendarField : TRUNCATING_FIELDS) { if (field == calendarField) { return; } calendar.set(calendarField, calendar.getActualMinimum(calendarField)); } }
From source file:org.dspace.app.statistics.CreateStatReport.java
/** * This script starts from the year and month specified below and loops each month until the current month * generating a monthly aggregation files for the DStat system. * //from ww w . j a va2s. co m * @throws Exception */ private static void statInitial() throws Exception { //Output Prefix String outputPrefix = "dspace-log-monthly-"; // set up our command line variables String myLogDir = null; String myFileTemplate = null; String myConfigFile = null; StringBuffer myOutFile = null; Date myStartDate = null; Date myEndDate = null; boolean myLookUp = false; Calendar reportEndDate = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); Calendar currentMonth = (Calendar) reportStartDate.clone(); while (currentMonth.before(reportEndDate)) { Calendar start = new GregorianCalendar(currentMonth.get(Calendar.YEAR), currentMonth.get(Calendar.MONTH), currentMonth.getActualMinimum(Calendar.DAY_OF_MONTH)); myStartDate = start.getTime(); Calendar end = new GregorianCalendar(currentMonth.get(Calendar.YEAR), currentMonth.get(Calendar.MONTH), currentMonth.getActualMaximum(Calendar.DAY_OF_MONTH)); myEndDate = end.getTime(); myOutFile = new StringBuffer(outputLogDirectory); myOutFile.append(outputPrefix); myOutFile.append(currentMonth.get(Calendar.YEAR)); myOutFile.append("-"); myOutFile.append(currentMonth.get(Calendar.MONTH) + 1); myOutFile.append(outputSuffix); LogAnalyser.processLogs(context, myLogDir, myFileTemplate, myConfigFile, myOutFile.toString(), myStartDate, myEndDate, myLookUp); currentMonth.add(Calendar.MONTH, 1); } }
From source file:de.mpg.escidoc.services.reporting.ReportFHI.java
public static String[] getStartEndDateOfQuery() { SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy-MM-"); int months;//from w ww .j ava 2s . c om try { months = new Integer(rprops.getProperty("FHI.report.months.range")).intValue(); } catch (Exception e) { throw new RuntimeException("Cannot read/convert FHI.report.months.range:", e); } ; //from Calendar fromMonth = GregorianCalendar.getInstance(); fromMonth.add(Calendar.MONTH, -months); String fromYearMonth = dateformatter.format(fromMonth.getTime()); //to Calendar toMonth = GregorianCalendar.getInstance(); toMonth.add(Calendar.MONTH, -1); String toYearMonth = dateformatter.format(toMonth.getTime()); return new String[] { fromYearMonth + String.format("%02d", fromMonth.getActualMinimum(Calendar.DAY_OF_MONTH)), toYearMonth + toMonth.getActualMaximum(Calendar.DAY_OF_MONTH) }; }
From source file:de.mpg.mpdl.inge.reporting.ReportFHI.java
public static String[] getStartEndDateOfQuery() { SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy-MM-"); int months;//from ww w. ja va 2 s .c o m try { months = new Integer(rprops.getProperty("FHI.report.months.range")).intValue(); } catch (Exception e) { throw new RuntimeException("Cannot read/convert FHI.report.months.range:", e); } ; // from Calendar fromMonth = GregorianCalendar.getInstance(); fromMonth.add(Calendar.MONTH, -months); String fromYearMonth = dateformatter.format(fromMonth.getTime()); // to Calendar toMonth = GregorianCalendar.getInstance(); toMonth.add(Calendar.MONTH, -1); String toYearMonth = dateformatter.format(toMonth.getTime()); return new String[] { fromYearMonth + String.format("%02d", fromMonth.getActualMinimum(Calendar.DAY_OF_MONTH)), toYearMonth + toMonth.getActualMaximum(Calendar.DAY_OF_MONTH) }; }
From source file:org.mifos.framework.util.helpers.DateUtils.java
public static Calendar getFistDayOfYearAfterNextYear() { Calendar cal = getCurrentDateCalendar(); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DATE)); Calendar cal1 = getCurrentDateCalendar(); cal1.set(cal.get(Calendar.YEAR) + 2, cal.get(Calendar.MONTH), cal.get(Calendar.DATE), 0, 0, 0); return cal1;/*from w ww . j a v a 2s .c o m*/ }
From source file:org.mifos.framework.util.helpers.DateUtils.java
public static Calendar getFistDayOfNextYear(Calendar cal) { cal.roll(Calendar.YEAR, 1);/*w w w. jav a2 s . c om*/ cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DATE)); Calendar cal1 = new DateTimeService().getCurrentDateTime().toGregorianCalendar(); cal1.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE), 0, 0, 0); return cal1; }
From source file:com.gnizr.core.util.GnizrDaoUtil.java
/** * Returns a <code>Date</code> object that represents the beginning * hour,min,second of a day (i.e., 00:00:00). The returned object shares the * same year, month, day values as the input <code>date</code> * // w ww . j a v a 2s . co m * @param date * an instantiated date * @return the beginning hour/min/sec of <code>date</code> */ public static Date toDayBegins(Date date) { Calendar cal = GregorianCalendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, cal.getActualMinimum(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, cal.getActualMinimum(Calendar.MINUTE)); cal.set(Calendar.SECOND, cal.getActualMinimum(Calendar.SECOND)); return cal.getTime(); }
From source file:rzd.vivc.documentexamination.form.service.DateFilterServiceWithCalendar.java
@Override public DateFilter createFirstAndLastDayOfMonth(Date dayOfMonth) { Calendar calendar = Calendar.getInstance(); calendar.setTime(dayOfMonth);//from w w w . j av a 2 s .c om calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); // ? ?? Date start = calendar.getTime(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); Date finish = calendar.getTime(); return new DateFilter(start, finish); }