List of usage examples for org.joda.time DateTime toDateMidnight
@Deprecated
public DateMidnight toDateMidnight()
DateMidnight
using the same millis and chronology. From source file:org.encuestame.utils.DateUtil.java
License:Apache License
/** * Retrieve next day mid night date.//from w w w . ja v a2s.c om * @return {@link Date} */ public static Date getNextDayMidnightDate() { DateTime midNight = new DateTime(); midNight = midNight.plusDays(1); final DateMidnight midnightDate = midNight.toDateMidnight(); return midnightDate.toDate(); }
From source file:org.encuestame.utils.DateUtil.java
License:Apache License
/** * Retrieve before day midnight./* w ww . j a v a 2s . c o m*/ * @return */ public static Date getBeforeDayMidnightDate() { DateTime midNight = new DateTime(); midNight = midNight.plusDays(-1); final DateMidnight midnightDate = midNight.toDateMidnight(); return midnightDate.toDate(); }
From source file:org.fenixedu.academic.domain.accounting.installments.InstallmentForFirstTimeStudents.java
License:Open Source License
private int getNumberOfMonthsToChargePenalty(final Event event, final DateTime when) { final Period period = new Period(getWhenStartToApplyPenalty(event, when), when.toDateMidnight()); final int numberOfMonths = (period.getYears() * 12) + (period.getMonths() + 1); if (getMaxMonthsToApplyPenalty() == null) { return numberOfMonths; } else {/*from w ww . j a v a 2s .c o m*/ return numberOfMonths < getMaxMonthsToApplyPenalty() ? numberOfMonths : getMaxMonthsToApplyPenalty(); } }
From source file:org.fenixedu.academic.domain.accounting.installments.InstallmentWithMonthlyPenalty.java
License:Open Source License
protected int getNumberOfMonthsToChargePenalty(DateTime when) { final Period period = new Period(getWhenStartToApplyPenalty().withDayOfMonth(1).toDateMidnight(), when.toDateMidnight()); final int numberOfMonths = (period.getYears() * 12) + (period.getMonths() + 1); if (getMaxMonthsToApplyPenalty() == null) { return numberOfMonths; } else {//from ww w . java 2 s . c o m return numberOfMonths < getMaxMonthsToApplyPenalty() ? numberOfMonths : getMaxMonthsToApplyPenalty(); } }
From source file:org.fenixedu.academic.dto.resourceAllocationManager.SpaceOccupationEventBean.java
License:Open Source License
public String getPresentationInterval() { final DateTime start = interval.getStart(); final DateTime end = interval.getEnd(); final DateMidnight dateMidnight = start.toDateMidnight(); if (dateMidnight.equals(end.toDateMidnight())) { return String.format("%s : %s as %s", dateMidnight.toString(DATE_FORMAT), getTime(start), getTime(end)); }//from w w w . j a v a2s . c o m return interval.toString(); }
From source file:org.fenixedu.academic.dto.resourceAllocationManager.SpaceOccupationEventBean.java
License:Open Source License
public DateMidnight getDateDay() { final DateTime start = interval.getStart(); final DateTime end = interval.getEnd(); final DateMidnight dateMidnight = start.toDateMidnight(); if (dateMidnight.equals(end.toDateMidnight())) { return dateMidnight; }/*w w w .j a v a 2 s . co m*/ return null; }
From source file:org.fenixedu.academic.ui.struts.action.publicRelationsOffice.AlumniInformationAction.java
License:Open Source License
public ActionForward showAlumniStatistics(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { Map<Long, Integer> registrationsByDay = new TreeMap<>(); int totalAlumniCount = Bennu.getInstance().getAlumnisSet().size(); int newAlumniCount = 0; int registeredAlumniCount = 0; for (Alumni alumni : Bennu.getInstance().getAlumnisSet()) { if (alumni.hasStartedPublicRegistry()) { newAlumniCount++;//from w w w . j a va 2 s . co m } if (alumni.hasFinishedPublicRegistry()) { registeredAlumniCount++; } DateTime whenRegistered = alumni.getRegisteredWhen(); if (whenRegistered != null) { // long time = // whenRegistered.toLocalDate().toDateTimeAtStartOfDay().getMillis(); long time = whenRegistered.toDateMidnight().getMillis(); Integer count = registrationsByDay.get(time); registrationsByDay.put(time, count == null ? 1 : count + 1); } } int jobCount = Bennu.getInstance().getJobsSet().size(); int formationCount = 0; for (Qualification q : Bennu.getInstance().getQualificationsSet()) { if (q.getClass().equals(Formation.class)) { formationCount++; } } request.setAttribute("chartData", createJsonArray(registrationsByDay)); request.setAttribute("statistics1", RoleType.ALUMNI.actualGroup().getMembers().distinct().count()); request.setAttribute("statistics2", totalAlumniCount); request.setAttribute("statistics3", newAlumniCount); request.setAttribute("statistics4", registeredAlumniCount); request.setAttribute("statistics5", jobCount); request.setAttribute("statistics6", formationCount); request.setAttribute("doneJobs", AlumniReportFile.readDoneJobs()); request.setAttribute("undoneJobs", AlumniReportFile.readUndoneJobs()); request.setAttribute("canRequestReport", AlumniReportFile.canRequestReport()); return mapping.findForward("alumni.showAlumniStatistics"); }
From source file:org.fracturedatlas.athena.reports.manager.GlanceReporter.java
License:Open Source License
private Boolean soldToday(DateTime now, PTicket ticket) { try {//www .j a v a 2 s . c om DateTime soldAt = DateUtil.parseDateTime(ticket.get("soldAt")); return soldAt.isAfter(now.toDateMidnight()); } catch (Exception e) { logger.error("soldAt of ticket [{}] was either null or in incorrect format", ticket.getId()); logger.error("{}", e.getMessage()); } return false; }
From source file:org.jasig.portal.portlets.statistics.BaseStatisticsReportController.java
License:Apache License
/** * Build the aggregation {@link DataTable} *///from w w w . j a v a 2 s. c om protected final DataTable buildAggregationReport(F form) throws TypeMismatchException { //Pull data out of form for per-group fetching final AggregationInterval interval = form.getInterval(); final DateMidnight start = form.getStart(); final DateMidnight end = form.getEnd(); final DateTime startDateTime = start.toDateTime(); //Use a query end of the end date at 23:59:59 final DateTime endDateTime = end.plusDays(1).toDateTime().minusSeconds(1); //Get the list of DateTimes used on the X axis in the report final List<DateTime> reportTimes = this.intervalHelper.getIntervalStartDateTimesBetween(interval, startDateTime, endDateTime, maxIntervals); final Map<D, SortedSet<T>> groupedAggregations = createColumnDiscriminatorMap(form); //Determine the ValueType of the date/time column. Use the most specific column type possible final ValueType dateTimeColumnType; if (interval.isHasTimePart()) { //If start/end are the same day just display the time if (startDateTime.toDateMidnight().equals(endDateTime.toDateMidnight())) { dateTimeColumnType = ValueType.TIMEOFDAY; } //interval has time data and start/end are on different days, show full date time else { dateTimeColumnType = ValueType.DATETIME; } } //interval is date only else { dateTimeColumnType = ValueType.DATE; } //Setup the date/time column description final ColumnDescription dateTimeColumn; switch (dateTimeColumnType) { case TIMEOFDAY: { dateTimeColumn = new ColumnDescription("time", dateTimeColumnType, "Time"); break; } default: { dateTimeColumn = new ColumnDescription("date", dateTimeColumnType, "Date"); } } final DataTable table = new JsonDataTable(); table.addColumn(dateTimeColumn); //Setup columns in the DataTable final Set<D> columnGroups = groupedAggregations.keySet(); for (final D columnMapping : columnGroups) { final Collection<ColumnDescription> columnDescriptions = this.getColumnDescriptions(columnMapping, form); table.addColumns(columnDescriptions); } //Query for all aggregation data in the time range for all groups. Only the //interval and discriminator data is used from the keys. final Set<K> keys = createAggregationsQueryKeyset(columnGroups, form); final BaseAggregationDao<T, K> baseAggregationDao = this.getBaseAggregationDao(); final Collection<T> aggregations = baseAggregationDao.getAggregations(startDateTime, endDateTime, keys, extractGroupsArray(columnGroups)); //Organize the results by group and sort them chronologically by adding them to the sorted set for (final T aggregation : aggregations) { final D discriminator = aggregation.getAggregationDiscriminator(); final SortedSet<T> results = groupedAggregations.get(discriminator); results.add(aggregation); } //Build Map from discriminator column mapping to result iterator to allow putting results into //the correct column AND the correct time slot in the column Comparator<? super D> comparator = getDiscriminatorComparator(); final Map<D, PeekingIterator<T>> groupedAggregationIterators = new TreeMap<D, PeekingIterator<T>>( (comparator)); for (final Entry<D, SortedSet<T>> groupedAggregationEntry : groupedAggregations.entrySet()) { groupedAggregationIterators.put(groupedAggregationEntry.getKey(), Iterators.peekingIterator(groupedAggregationEntry.getValue().iterator())); } /* * populate the data, filling in blank spots. The full list of interval DateTimes is used to create every row in the * query range. Then the iterator */ for (final DateTime rowTime : reportTimes) { // create the row final TableRow row = new TableRow(); // add the date to the first cell final Value dateTimeValue; switch (dateTimeColumnType) { case DATE: { dateTimeValue = new DateValue(rowTime.getYear(), rowTime.getMonthOfYear() - 1, rowTime.getDayOfMonth()); break; } case TIMEOFDAY: { dateTimeValue = new TimeOfDayValue(rowTime.getHourOfDay(), rowTime.getMinuteOfHour(), 0); break; } default: { dateTimeValue = new DateTimeValue(rowTime.getYear(), rowTime.getMonthOfYear() - 1, rowTime.getDayOfMonth(), rowTime.getHourOfDay(), rowTime.getMinuteOfHour(), 0, 0); break; } } row.addCell(new TableCell(dateTimeValue)); for (final PeekingIterator<T> groupedAggregationIteratorEntry : groupedAggregationIterators.values()) { List<Value> values = null; if (groupedAggregationIteratorEntry.hasNext()) { final T aggr = groupedAggregationIteratorEntry.peek(); if (rowTime.equals(aggr.getDateTime())) { //Data is for the correct time slot, advance the iterator groupedAggregationIteratorEntry.next(); values = createRowValues(aggr, form); } } //Gap in the data, fill it in using a null aggregation if (values == null) { values = createRowValues(null, form); } //Add the values to the row for (final Value value : values) { row.addCell(value); } } table.addRow(row); } return table; }
From source file:org.jasig.portlet.blackboardvcportlet.service.SessionForm.java
License:Apache License
public void setStartTime(DateTime startTime) { startDate = startTime.toDateMidnight(); startHour = startTime.getHourOfDay(); startMinute = startTime.getMinuteOfHour(); startHourMinute = new LocalTime(startTime); }