List of usage examples for java.util Calendar getMinimum
public abstract int getMinimum(int field);
Calendar
instance. From source file:com.autentia.intra.bean.activity.GlobalHoursReportBean.java
public float getTotalHours() { ActivitySearch search = new ActivitySearch(); Calendar init = Calendar.getInstance(); init.setTime(startDate);/*from w w w . ja v a2 s . c o m*/ Calendar last = Calendar.getInstance(); last.setTime(endDate); init.set(Calendar.HOUR_OF_DAY, init.getMinimum(Calendar.HOUR_OF_DAY)); init.set(Calendar.MINUTE, init.getMinimum(Calendar.MINUTE)); init.set(Calendar.SECOND, init.getMinimum(Calendar.SECOND)); init.set(Calendar.MILLISECOND, init.getMinimum(Calendar.MILLISECOND)); last.set(Calendar.HOUR_OF_DAY, last.getMaximum(Calendar.HOUR_OF_DAY)); last.set(Calendar.MINUTE, last.getMaximum(Calendar.MINUTE)); last.set(Calendar.SECOND, last.getMaximum(Calendar.SECOND)); last.set(Calendar.MILLISECOND, last.getMaximum(Calendar.MILLISECOND)); search.setStartStartDate(init.getTime()); search.setEndStartDate(last.getTime()); if (billable) search.setBillable(true); // Search activities during indicated dates List<Activity> activities = manager.getAllEntities(search, new SortCriteria("role.project.client.name")); // Search for projects in activities and create the global list. float totalHours = 0.0f; for (Activity act : activities) { float horas = act.getDuration() / 60.0f; totalHours = totalHours + horas; } return totalHours; }
From source file:com.autentia.intra.bean.activity.GlobalHoursReportBean.java
public float getNextUserTotal() { ActivitySearch search = new ActivitySearch(); Calendar init = Calendar.getInstance(); init.setTime(startDate);/* ww w. ja v a2 s . c o m*/ Calendar last = Calendar.getInstance(); last.setTime(endDate); init.set(Calendar.HOUR_OF_DAY, init.getMinimum(Calendar.HOUR_OF_DAY)); init.set(Calendar.MINUTE, init.getMinimum(Calendar.MINUTE)); init.set(Calendar.SECOND, init.getMinimum(Calendar.SECOND)); init.set(Calendar.MILLISECOND, init.getMinimum(Calendar.MILLISECOND)); last.set(Calendar.HOUR_OF_DAY, last.getMaximum(Calendar.HOUR_OF_DAY)); last.set(Calendar.MINUTE, last.getMaximum(Calendar.MINUTE)); last.set(Calendar.SECOND, last.getMaximum(Calendar.SECOND)); last.set(Calendar.MILLISECOND, last.getMaximum(Calendar.MILLISECOND)); search.setStartStartDate(init.getTime()); search.setEndStartDate(last.getTime()); if (billable) search.setBillable(true); if (iterator == null) iterator = getUsers().iterator(); User user = null; try { user = iterator.next(); } catch (NoSuchElementException e) { iterator = getUsers().iterator(); user = iterator.next(); } search.setUser(user); // Search activities during indicated dates List<Activity> activities = manager.getAllEntities(search, new SortCriteria("role.project.client.name")); // Search for projects in activities and create the global list. float totalHours = 0.0f; for (Activity act : activities) { float horas = act.getDuration() / 60.0f; totalHours = totalHours + horas; } return totalHours; }
From source file:com.autentia.intra.bean.activity.GlobalHoursReportBean.java
public List<GlobalHourReport> getAll() { // Retrieve activities for every User during that period of time ActivitySearch search = new ActivitySearch(); Calendar init = Calendar.getInstance(); init.setTime(startDate);//w w w.ja va 2 s. com Calendar last = Calendar.getInstance(); last.setTime(endDate); init.set(Calendar.HOUR_OF_DAY, init.getMinimum(Calendar.HOUR_OF_DAY)); init.set(Calendar.MINUTE, init.getMinimum(Calendar.MINUTE)); init.set(Calendar.SECOND, init.getMinimum(Calendar.SECOND)); init.set(Calendar.MILLISECOND, init.getMinimum(Calendar.MILLISECOND)); last.set(Calendar.HOUR_OF_DAY, last.getMaximum(Calendar.HOUR_OF_DAY)); last.set(Calendar.MINUTE, last.getMaximum(Calendar.MINUTE)); last.set(Calendar.SECOND, last.getMaximum(Calendar.SECOND)); last.set(Calendar.MILLISECOND, last.getMaximum(Calendar.MILLISECOND)); search.setStartStartDate(init.getTime()); search.setEndStartDate(last.getTime()); List<GlobalHourReport> listGlobal = new ArrayList<GlobalHourReport>(); if (billable) search.setBillable(true); // Search activities during indicated dates List<Activity> activities = manager.getAllEntities(search, new SortCriteria("role.project.client.name")); // Search for projects in activities and create the global list. for (Activity act : activities) { Project proj = act.getRole().getProject(); GlobalHourReport unit = new GlobalHourReport(); unit.setProject(proj); // an entry in the list represents a project if (!listGlobal.contains(unit)) listGlobal.add(unit); // Retrieve the stored unit and save hours GlobalHourReport storedUnit = listGlobal.get(listGlobal.indexOf(unit)); float horas = act.getDuration() / 60.0f; storedUnit.setUserHours(act.getUser(), horas); storedUnit.setIterator(usuarios.iterator()); } return listGlobal; }
From source file:com.autentia.tnt.bean.activity.GlobalHoursReportBean.java
public float getTotalHours() { ActivitySearch search = new ActivitySearch(); Calendar init = Calendar.getInstance(); init.setTime(startDate);// w ww.j a v a 2s .c o m Calendar last = Calendar.getInstance(); last.setTime(endDate); init.set(Calendar.HOUR_OF_DAY, init.getMinimum(Calendar.HOUR_OF_DAY)); init.set(Calendar.MINUTE, init.getMinimum(Calendar.MINUTE)); init.set(Calendar.SECOND, init.getMinimum(Calendar.SECOND)); init.set(Calendar.MILLISECOND, init.getMinimum(Calendar.MILLISECOND)); last.set(Calendar.HOUR_OF_DAY, last.getMaximum(Calendar.HOUR_OF_DAY)); last.set(Calendar.MINUTE, last.getMaximum(Calendar.MINUTE)); last.set(Calendar.SECOND, last.getMaximum(Calendar.SECOND)); last.set(Calendar.MILLISECOND, last.getMaximum(Calendar.MILLISECOND)); search.setStartStartDate(init.getTime()); search.setEndStartDate(last.getTime()); if (billable) search.setBillable(true); // Search activities during indicated dates List<Activity> activities = manager.getAllEntities(search, new SortCriteria("role.project.client.name")); // Search for projects in activities and create the global list. float totalHours = 0.0f; for (Activity act : activities) { float horas = act.getDuration() / 60.0f; totalHours = totalHours + horas; } return totalHours; }
From source file:com.autentia.tnt.bean.activity.GlobalHoursReportBean.java
public float getNextUserTotal() { ActivitySearch search = new ActivitySearch(); Calendar init = Calendar.getInstance(); init.setTime(startDate);/*from w w w. j a v a2s.c o m*/ Calendar last = Calendar.getInstance(); last.setTime(endDate); init.set(Calendar.HOUR_OF_DAY, init.getMinimum(Calendar.HOUR_OF_DAY)); init.set(Calendar.MINUTE, init.getMinimum(Calendar.MINUTE)); init.set(Calendar.SECOND, init.getMinimum(Calendar.SECOND)); init.set(Calendar.MILLISECOND, init.getMinimum(Calendar.MILLISECOND)); last.set(Calendar.HOUR_OF_DAY, last.getMaximum(Calendar.HOUR_OF_DAY)); last.set(Calendar.MINUTE, last.getMaximum(Calendar.MINUTE)); last.set(Calendar.SECOND, last.getMaximum(Calendar.SECOND)); last.set(Calendar.MILLISECOND, last.getMaximum(Calendar.MILLISECOND)); search.setStartStartDate(init.getTime()); search.setEndStartDate(last.getTime()); if (billable) search.setBillable(true); if (iterator == null) iterator = getUsers().iterator(); User user = null; try { user = iterator.next(); } catch (NoSuchElementException e) { iterator = getUsers().iterator(); user = iterator.next(); } search.setUser(user); // Search activities during indicated dates List<Activity> activities = manager.getAllEntities(search, new SortCriteria("role.project.client.name")); // Search for projects in activities and create the global list. float totalHours = 0.0f; for (Activity act : activities) { float horas = act.getDuration() / 60.0f; totalHours = totalHours + horas; } return totalHours; }
From source file:com.autentia.tnt.bean.activity.GlobalHoursReportBean.java
public List<GlobalHourReport> getAll() { // Retrieve activities for every User during that period of time ActivitySearch search = new ActivitySearch(); Calendar init = Calendar.getInstance(); init.setTime(startDate);// w w w . j a v a 2 s .c om Calendar last = Calendar.getInstance(); last.setTime(endDate); init.set(Calendar.HOUR_OF_DAY, init.getMinimum(Calendar.HOUR_OF_DAY)); init.set(Calendar.MINUTE, init.getMinimum(Calendar.MINUTE)); init.set(Calendar.SECOND, init.getMinimum(Calendar.SECOND)); init.set(Calendar.MILLISECOND, init.getMinimum(Calendar.MILLISECOND)); last.set(Calendar.HOUR_OF_DAY, last.getMaximum(Calendar.HOUR_OF_DAY)); last.set(Calendar.MINUTE, last.getMaximum(Calendar.MINUTE)); last.set(Calendar.SECOND, last.getMaximum(Calendar.SECOND)); last.set(Calendar.MILLISECOND, last.getMaximum(Calendar.MILLISECOND)); search.setStartStartDate(init.getTime()); search.setEndStartDate(last.getTime()); List<GlobalHourReport> listGlobal = new ArrayList<GlobalHourReport>(); if (billable) search.setBillable(true); // Search activities during indicated dates List<Activity> activities = manager.getAllEntities(search, new SortCriteria("role.project.client.name")); // Search for projects in activities and create the global list. for (Activity act : activities) { Project proj = act.getRole().getProject(); GlobalHourReport unit = new GlobalHourReport(); unit.setProject(proj); // an entry in the list represents a project if (!listGlobal.contains(unit)) listGlobal.add(unit); // Retrieve the stored unit and save hours GlobalHourReport storedUnit = listGlobal.get(listGlobal.indexOf(unit)); float horas = act.getDuration() / 60.0f; storedUnit.setUserHours(act.getUser(), horas); storedUnit.setIterator(usuarios.iterator()); } return listGlobal; }
From source file:it.scoppelletti.mobilepower.types.SimpleDate.java
/** * Costruttore./* w ww. ja va2 s . c o m*/ * * @param year Anno. * @param month Mese. * @param day Giorno. */ public SimpleDate(int year, int month, int day) { int min, max; Calendar cal = Calendar.getInstance(); min = cal.getMinimum(Calendar.YEAR); max = cal.getMaximum(Calendar.YEAR); if (year < min || year > max) { throw new IllegalArgumentException( String.format("Argument year %1$d is ouf of range [%2$d, %3$d].", year, min, max)); } cal.set(Calendar.YEAR, year); min = cal.getActualMinimum(Calendar.MONTH); max = cal.getActualMaximum(Calendar.MONTH); if (month < min || month > max) { throw new IllegalArgumentException( String.format("Argument month %1$d is ouf of range [%2$d, %3$d].", month, min, max)); } cal.set(Calendar.MONTH, month); min = cal.getActualMinimum(Calendar.DAY_OF_MONTH); max = cal.getActualMaximum(Calendar.DAY_OF_MONTH); if (day < min || day > max) { throw new IllegalArgumentException( String.format("Argument day %1$d is ouf of range [%2$d, %3$d].", day, min, max)); } myYear = year; myMonth = month; myDay = day; }
From source file:com.sentaca.spring.smpp.jsmpp.JSMPPGateway.java
private String formatTimeFromHours(int timeInHours) { if (timeInHours < 0) { return null; }//from w w w .j av a 2 s. co m Calendar cDate = Calendar.getInstance(); cDate.clear(); cDate.set(Calendar.YEAR, 0); cDate.add(Calendar.HOUR, timeInHours); int years = cDate.get(Calendar.YEAR) - cDate.getMinimum(Calendar.YEAR); int months = cDate.get(Calendar.MONTH); int days = cDate.get(Calendar.DAY_OF_MONTH) - 1; int hours = cDate.get(Calendar.HOUR_OF_DAY); String yearsString = (years < 10) ? "0" + years : years + ""; String monthsString = (months < 10) ? "0" + months : months + ""; String daysString = (days < 10) ? "0" + days : days + ""; String hoursString = (hours < 10) ? "0" + hours : hours + ""; return yearsString + monthsString + daysString + hoursString + "0000000R"; }
From source file:com.rogchen.common.xml.UtilDateTime.java
public static String getFirstDayOfMonth(int year, int month) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month - 1); cal.set(Calendar.DAY_OF_MONTH, cal.getMinimum(Calendar.DATE)); return new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()); }
From source file:com.autentia.intra.bean.holiday.HolidayBean.java
/** * List holidays. Order depends on Faces parameter sort. * * @return the list of all holidays sorted by requested criterion */// ww w.ja va2s . com public List<Holiday> getAll() { if (selectedYear != null) { Calendar calMin = Calendar.getInstance(); calMin.setTime(selectedYear); calMin.set(Calendar.MONTH, calMin.getMinimum(Calendar.MONTH)); calMin.set(Calendar.DAY_OF_MONTH, calMin.getMinimum(Calendar.DAY_OF_MONTH)); calMin.set(Calendar.HOUR_OF_DAY, calMin.getMinimum(Calendar.HOUR_OF_DAY)); calMin.set(Calendar.MINUTE, calMin.getMinimum(Calendar.MINUTE)); calMin.set(Calendar.SECOND, calMin.getMinimum(Calendar.SECOND)); calMin.set(Calendar.MILLISECOND, calMin.getMinimum(Calendar.MILLISECOND)); Calendar calMax = Calendar.getInstance(); calMax.setTime(selectedYear); calMax.set(Calendar.MONTH, calMax.getMaximum(Calendar.MONTH)); calMax.set(Calendar.DAY_OF_MONTH, calMax.getMaximum(Calendar.DAY_OF_MONTH)); calMax.set(Calendar.HOUR_OF_DAY, calMax.getMaximum(Calendar.HOUR_OF_DAY)); calMax.set(Calendar.MINUTE, calMax.getMaximum(Calendar.MINUTE)); calMax.set(Calendar.SECOND, calMax.getMaximum(Calendar.SECOND)); calMax.set(Calendar.MILLISECOND, calMax.getMaximum(Calendar.MILLISECOND)); setSearchStartDate(calMin.getTime()); setSearchStartDateValid(true); setSearchEndDate(calMax.getTime()); setSearchEndDateValid(true); } return manager.getAllEntities(search, new SortCriteria(sortColumn, sortAscending)); }