List of usage examples for org.joda.time DateTime minusDays
public DateTime minusDays(int days)
From source file:com.google.api.ads.adwords.awreporting.model.entities.dateranges.Last7DaysDateRangeHandler.java
License:Open Source License
@Override public DateTime retrieveDateStart(DateTime date) { return date.minusDays(7); }
From source file:com.google.api.ads.adwords.awreporting.model.entities.dateranges.LastMonthDateRangeHandler.java
License:Open Source License
@Override public DateTime retrieveDateEnd(DateTime date) { DateTime sameDate = new DateTime(date.getYear(), date.getMonthOfYear(), 1, 12, 0); return sameDate.minusDays(1); }
From source file:com.google.api.ads.adwords.awreporting.model.entities.dateranges.ThisMonthDateRangeHandler.java
License:Open Source License
@Override public DateTime retrieveDateEnd(DateTime date) { DateTime plusMonth = date.plusMonths(1); plusMonth = new DateTime(plusMonth.getYear(), plusMonth.getMonthOfYear(), 1, 12, 0); return plusMonth.minusDays(1); }
From source file:com.google.api.ads.adwords.awreporting.model.entities.dateranges.YesterdayDateRangeHandler.java
License:Open Source License
@Override public DateTime retrieveDateStart(DateTime date) { return date.minusDays(1); }
From source file:com.google.api.ads.adwords.awreporting.model.entities.dateranges.YesterdayDateRangeHandler.java
License:Open Source License
@Override public DateTime retrieveDateEnd(DateTime date) { return date.minusDays(1); }
From source file:com.hmsinc.epicenter.surveillance.event.EventService.java
License:Open Source License
/** * @param task//from w ww . ja v a 2 s .c om * @param method * @param geography * @param classification * @param analysisTimestamp * @return */ @Transactional private boolean checkForRecentAnomaly(final SurveillanceTask task, final SurveillanceMethod method, final SurveillanceSet set, final Geography geography, final Classification classification, final DateTime analysisTime) { boolean rtn = false; final Anomaly anomaly = surveillanceRepository.getLatestAnomaly(geography, classification, task, method, set, analysisTime); if (anomaly != null && anomaly.getAnalysisTimestamp().isAfter(analysisTime.minusDays(1))) { incrementLastSeenCounter(anomaly); logger.debug("Found recent existing anomaly '{}', not creating new one", anomaly); rtn = true; } return rtn; }
From source file:com.hmsinc.epicenter.webapp.remoting.ForecastingService.java
License:Open Source License
@Secured("ROLE_USER") @Transactional(readOnly = true)//from w w w . j a v a 2 s .co m @RemoteMethod public String getSeasonalTrendChart(final AnalysisParametersDTO paramsDTO) { final AnalysisParameters params = convertParameters(paramsDTO); // 60 day window final DateTime windowStart = params.getEndDate().minusDays(59); // Set the start date back 1 year + 60 days params.setStartDate(windowStart.minusYears(1).minusDays(59)); final TimeSeriesChart chart = new TimeSeriesChart(); final TimeSeries ts = queryService.queryForTimeSeries(params, paramsDTO.getAlgorithmName(), null); if (ts != null) { final TimeSeries forecast = waveletSeasonalTrendForecaster.process(ts.after(windowStart), ts.before(windowStart.minusDays(1)), null); final TimeSeries known = forecast.before(params.getEndDate()); final TimeSeries predicted = forecast.after(params.getEndDate().plusDays(1)); chart.addBand("70% Confidence Prediction", predicted, ResultType.LOWER_BOUND_70, ResultType.UPPER_BOUND_70, new Color(0x0072bf), new Color(0x0072bf)); chart.addBand("80% Confidence Prediction", predicted, ResultType.LOWER_BOUND_80, ResultType.UPPER_BOUND_80, new Color(0x0099ff), new Color(0x0099ff)); chart.addBand("90% Confidence Prediction", predicted, ResultType.LOWER_BOUND_90, ResultType.UPPER_BOUND_90, new Color(0x3fb2ff), new Color(0x3fb2ff)); chart.addBand("95% Confidence Prediction", predicted, ResultType.LOWER_BOUND_95, ResultType.UPPER_BOUND_95, new Color(0xbfe5ff), new Color(0xbfe5ff)); chart.add("Actual Value", known, ChartColor.VALUE.getColor(), LineStyle.DOTTED); chart.add("Actual Trend", known, ResultType.TREND, ChartColor.VALUE.getColor(), LineStyle.THICK); final DateTime knownFirst = known.first().getTime(); final DateTime predictedFirst = predicted.first().getTime(); final Marker marker = new IntervalMarker( new Day(knownFirst.getDayOfMonth(), knownFirst.getMonthOfYear(), knownFirst.getYear()) .getFirstMillisecond(), new Day(predictedFirst.getDayOfMonth(), predictedFirst.getMonthOfYear(), predictedFirst.getYear()).getFirstMillisecond(), Color.LIGHT_GRAY, new BasicStroke(2.0f), null, null, 1.0f); marker.setAlpha(0.3f); chart.getMarkers().add(marker); chart.setYLabel(params.getDataRepresentation().getDisplayName()); chart.setAlwaysScaleFromZero(false); } return chartService.getChartURL(chart); }
From source file:com.hurence.logisland.util.time.DateUtil.java
License:Apache License
/** * build a list of n latest dates from today * * @param n nb days from now// ww w .jav a 2 s .com * @return something like {2014.05.12,2014.05.13} if today is 2014.05.13 and n = 2 */ public static String getLatestDaysFromNow(int n) { String dates = "{"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); DateTime start = new DateTime(); for (int i = 0; i < n; i++) { Date date = start.minusDays(i).toDate(); dates += sdf.format(date); if (i != n - 1) { dates += ","; } else { dates += "}"; } } log.info(dates); return dates; }
From source file:com.inkubator.hrm.service.impl.EmpDataServiceImpl.java
@Cacheable(value = "employeeResumeOnDashboard", key = "#companyId") @Transactional(readOnly = true, isolation = Isolation.REPEATABLE_READ, propagation = Propagation.SUPPORTS, timeout = 50) public EmployeeResumeDashboardModel getEmployeeResumeOnDashboard(Long companyId) { DateTime now = DateTime.now(); Long totalEmployee = empDataDao.getTotalEmpDataNotTerminate(); Long todayLeave = leaveImplementationDateDao.getTotalActualLeave(now.toDate(), companyId); Long todayBusinessTravel = businessTravelDao.getTotalActualBusinessTravel(now.toDate(), companyId); Long todayPermit = permitImplementationDao.getTotalActualPermit(now.toDate(), companyId); BioDataModel nearestBirthdayPerson = empDataDao.getEmpNameWithNearestBirthDate(); String nearestBirthday = nearestBirthdayPerson == null ? "N/A" : nearestBirthdayPerson.getFirstName() + " " + nearestBirthdayPerson.getLastName(); /**/*from ww w.j a va 2s .c o m*/ * kehadiran kemarin */ Long totalYesterdaySchedule = tempProcessReadFingerDao.getTotalByScheduleDate(now.minusDays(1).toDate(), companyId); Long totalYesterdayAttendance = tempProcessReadFingerDao .getTotalAttendanceByScheduleDate(now.minusDays(1).toDate(), companyId); BigDecimal yesterdayAttendance = new BigDecimal(0); if (totalYesterdaySchedule != 0 && totalYesterdayAttendance != 0) { yesterdayAttendance = new BigDecimal(totalYesterdayAttendance).multiply(new BigDecimal(100)) .divide(new BigDecimal(totalYesterdaySchedule), 2, RoundingMode.UP); } /** * perkiraan kehadiran hari ini = jadwal - (ijin+cuti+dinas) */ Long totalTodaySchedule = tempJadwalKaryawanDao.getTotalByTanggalWaktuKerja(now.toDate(), companyId); Long totalTodayAttendance = totalTodaySchedule - (todayLeave + todayBusinessTravel + todayPermit); BigDecimal todayAttendance = new BigDecimal(100); if (totalTodaySchedule != 0 && totalTodayAttendance != 0) { todayAttendance = new BigDecimal(totalTodayAttendance).multiply(new BigDecimal(100)) .divide(new BigDecimal(totalTodaySchedule), 2, RoundingMode.UP); } //set value to model EmployeeResumeDashboardModel model = new EmployeeResumeDashboardModel(); model.setTotalEmployee(totalEmployee); model.setTodayLeave(todayLeave); model.setTodayBusinessTravel(todayBusinessTravel); model.setYesterdayAttendance(yesterdayAttendance); model.setTodayAttendance(todayAttendance); model.setNearestBirthday(nearestBirthday); return model; }
From source file:com.inkubator.hrm.service.impl.WtPeriodeServiceImpl.java
@Override @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, timeout = 30) public WtPeriode getEntityByPreviousPayrollTypeActive() throws Exception { WtPeriode periode = wtPeriodeDao.getEntityByPayrollTypeActive(); DateTime dt = new DateTime(periode.getFromPeriode()); dt = dt.minusDays(1); return wtPeriodeDao.getEntityByDateBetween(dt.toDate()); }