List of usage examples for org.joda.time DateTime getMinuteOfDay
public int getMinuteOfDay()
From source file:kr.debop4j.timeperiod.tools.Times.java
License:Apache License
/** * ? ?? true false .// ww w .j av a 2 s .c o m * * @param left the left * @param right the right * @return the boolean */ public static boolean isSameMinute(DateTime left, DateTime right) { return isSameDay(left, right) && left.getMinuteOfDay() == right.getMinuteOfDay(); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.operator.SubmitPhotoAction.java
License:Open Source License
public ActionForward photoUpload(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { PhotographUploadBean photo = getRenderedObject(); RenderUtils.invalidateViewState();//from w w w . j a v a 2 s. c om String base64Thumbnail = request.getParameter("encodedThumbnail"); String base64Image = request.getParameter("encodedPicture"); if (base64Image != null && base64Thumbnail != null) { DateTime now = new DateTime(); photo.setFilename("mylovelypic_" + now.getYear() + now.getMonthOfYear() + now.getDayOfMonth() + now.getHourOfDay() + now.getMinuteOfDay() + now.getSecondOfMinute() + ".png"); photo.setBase64RawContent(base64Image.split(",")[1]); photo.setBase64RawThumbnail(base64Thumbnail.split(",")[1]); photo.setContentType(base64Image.split(",")[0].split(":")[1].split(";")[0]); } ActionMessages actionMessages = new ActionMessages(); if (photo.getFileInputStream() == null) { actionMessages.add("error", new ActionMessage("errors.fileRequired")); saveMessages(request, actionMessages); return preparePhotoUpload(mapping, actionForm, request, response); } if (ContentType.getContentType(photo.getContentType()) == null) { actionMessages.add("error", new ActionMessage("errors.unsupportedFile")); saveMessages(request, actionMessages); return preparePhotoUpload(mapping, actionForm, request, response); } if (photo.getRawSize() > MAX_RAW_SIZE) { actionMessages.add("error", new ActionMessage("errors.fileTooLarge")); saveMessages(request, actionMessages); photo.deleteTemporaryFiles(); return preparePhotoUpload(mapping, actionForm, request, response); } try { photo.processImage(); } catch (UnableToProcessTheImage e) { actionMessages.add("error", new ActionMessage("errors.unableToProcessImage")); saveMessages(request, actionMessages); photo.deleteTemporaryFiles(); return preparePhotoUpload(mapping, actionForm, request, response); } try { updatePersonPhoto(photo); } catch (Exception e) { actionMessages.add("error", new ActionMessage("errors.unableToSaveImage")); saveMessages(request, actionMessages); photo.deleteTemporaryFiles(); return preparePhotoUpload(mapping, actionForm, request, response); } actionMessages.add("success", new ActionMessage("label.operator.submit.ok", "")); saveMessages(request, actionMessages); return preparePhotoUpload(mapping, actionForm, request, response); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.person.UploadPhotoDA.java
License:Open Source License
public ActionForward upload(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { PhotographUploadBean photo = getRenderedObject(); RenderUtils.invalidateViewState();/*from w w w . j a v a2 s . co m*/ String base64Thumbnail = request.getParameter("encodedThumbnail"); String base64Image = request.getParameter("encodedPicture"); if (base64Image != null && base64Thumbnail != null) { DateTime now = new DateTime(); photo.setFilename("mylovelypic_" + now.getYear() + now.getMonthOfYear() + now.getDayOfMonth() + now.getHourOfDay() + now.getMinuteOfDay() + now.getSecondOfMinute() + ".png"); photo.setBase64RawContent(base64Image.split(",")[1]); photo.setBase64RawThumbnail(base64Thumbnail.split(",")[1]); photo.setContentType(base64Image.split(",")[0].split(":")[1].split(";")[0]); } ActionMessages actionMessages = new ActionMessages(); if (photo.getFileInputStream() == null) { actionMessages.add("fileRequired", new ActionMessage("errors.fileRequired")); saveMessages(request, actionMessages); return prepare(mapping, actionForm, request, response); } if (ContentType.getContentType(photo.getContentType()) == null) { actionMessages.add("fileUnsupported", new ActionMessage("errors.unsupportedFile")); saveMessages(request, actionMessages); return prepare(mapping, actionForm, request, response); } if (photo.getRawSize() > MAX_RAW_SIZE) { actionMessages.add("fileTooLarge", new ActionMessage("errors.fileTooLarge")); saveMessages(request, actionMessages); photo.deleteTemporaryFiles(); return prepare(mapping, actionForm, request, response); } try { photo.processImage(); } catch (UnableToProcessTheImage e) { actionMessages.add("unableToProcessImage", new ActionMessage("errors.unableToProcessImage")); saveMessages(request, actionMessages); photo.deleteTemporaryFiles(); return prepare(mapping, actionForm, request, response); } photo.createTemporaryFiles(); request.setAttribute("preview", true); request.setAttribute("photo", photo); return mapping.findForward("confirm"); }
From source file:org.fenixedu.academic.ui.struts.action.operator.SubmitPhotoAction.java
License:Open Source License
public ActionForward photoUpload(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { PhotographUploadBean photo = getRenderedObject(); RenderUtils.invalidateViewState();/* ww w. j a va 2 s.c om*/ String base64Thumbnail = request.getParameter("encodedThumbnail"); String base64Image = request.getParameter("encodedPicture"); if (base64Image != null && base64Thumbnail != null) { DateTime now = new DateTime(); photo.setFilename("mylovelypic_" + now.getYear() + now.getMonthOfYear() + now.getDayOfMonth() + now.getHourOfDay() + now.getMinuteOfDay() + now.getSecondOfMinute() + ".png"); photo.setBase64RawContent(base64Image.split(",")[1]); photo.setBase64RawThumbnail(base64Thumbnail.split(",")[1]); photo.setContentType(base64Image.split(",")[0].split(":")[1].split(";")[0]); } ActionMessages actionMessages = new ActionMessages(); try (InputStream stream = photo.getFileInputStream()) { if (stream == null) { actionMessages.add("error", new ActionMessage("errors.fileRequired")); saveMessages(request, actionMessages); return preparePhotoUpload(mapping, actionForm, request, response); } } if (ContentType.getContentType(photo.getContentType()) == null) { actionMessages.add("error", new ActionMessage("errors.unsupportedFile")); saveMessages(request, actionMessages); return preparePhotoUpload(mapping, actionForm, request, response); } if (photo.getRawSize() > MAX_RAW_SIZE) { actionMessages.add("error", new ActionMessage("errors.fileTooLarge")); saveMessages(request, actionMessages); photo.deleteTemporaryFiles(); return preparePhotoUpload(mapping, actionForm, request, response); } try { photo.processImage(); } catch (UnableToProcessTheImage e) { actionMessages.add("error", new ActionMessage("errors.unableToProcessImage")); saveMessages(request, actionMessages); photo.deleteTemporaryFiles(); return preparePhotoUpload(mapping, actionForm, request, response); } try { updatePersonPhoto(photo); } catch (Exception e) { actionMessages.add("error", new ActionMessage("errors.unableToSaveImage")); saveMessages(request, actionMessages); photo.deleteTemporaryFiles(); return preparePhotoUpload(mapping, actionForm, request, response); } actionMessages.add("success", new ActionMessage("label.operator.submit.ok", "")); saveMessages(request, actionMessages); return preparePhotoUpload(mapping, actionForm, request, response); }
From source file:org.fenixedu.academic.ui.struts.action.person.UploadPhotoDA.java
License:Open Source License
public ActionForward upload(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { PhotographUploadBean photo = getRenderedObject(); RenderUtils.invalidateViewState();//from w w w. ja va 2 s.c om String base64Thumbnail = request.getParameter("encodedThumbnail"); String base64Image = request.getParameter("encodedPicture"); if (base64Image != null && base64Thumbnail != null) { DateTime now = new DateTime(); photo.setFilename("mylovelypic_" + now.getYear() + now.getMonthOfYear() + now.getDayOfMonth() + now.getHourOfDay() + now.getMinuteOfDay() + now.getSecondOfMinute() + ".png"); photo.setBase64RawContent(base64Image.split(",")[1]); photo.setBase64RawThumbnail(base64Thumbnail.split(",")[1]); photo.setContentType(base64Image.split(",")[0].split(":")[1].split(";")[0]); } ActionMessages actionMessages = new ActionMessages(); try (InputStream stream = photo.getFileInputStream()) { if (stream == null) { actionMessages.add("fileRequired", new ActionMessage("errors.fileRequired")); saveMessages(request, actionMessages); return prepare(mapping, actionForm, request, response); } } if (ContentType.getContentType(photo.getContentType()) == null) { actionMessages.add("fileUnsupported", new ActionMessage("errors.unsupportedFile")); saveMessages(request, actionMessages); return prepare(mapping, actionForm, request, response); } if (photo.getRawSize() > MAX_RAW_SIZE) { actionMessages.add("fileTooLarge", new ActionMessage("errors.fileTooLarge")); saveMessages(request, actionMessages); photo.deleteTemporaryFiles(); return prepare(mapping, actionForm, request, response); } try { photo.processImage(); } catch (UnableToProcessTheImage e) { actionMessages.add("unableToProcessImage", new ActionMessage("errors.unableToProcessImage")); saveMessages(request, actionMessages); photo.deleteTemporaryFiles(); return prepare(mapping, actionForm, request, response); } photo.createTemporaryFiles(); request.setAttribute("preview", true); request.setAttribute("photo", photo); return mapping.findForward("confirm"); }
From source file:org.jgrasstools.hortonmachine.modules.hydrogeomorphology.energybalance.OmsEnergyBalance.java
License:Open Source License
@Execute public void process() throws Exception { outPnet = new HashMap<Integer, double[]>(); outPrain = new HashMap<Integer, double[]>(); outPsnow = new HashMap<Integer, double[]>(); outSwe = new HashMap<Integer, double[]>(); outNetradiation = new HashMap<Integer, double[]>(); outNetshortradiation = new HashMap<Integer, double[]>(); if (safePoint == null) safePoint = new SafePoint(); // retrieve number of bands num_EI = 0;//ww w.jav a 2 s . c om for (EIEnergy energy : inEnergy) { int j = energy.energeticBandId; if (j > num_EI) { num_EI = j; } } num_EI++; num_ES = 0; for (EIAreas area : inAreas) { int j = area.altimetricBandId; if (j > num_ES) { num_ES = j; } } num_ES++; if (basinid2BasinindexMap == null) { // get basin features from feature link basinsFeatures = new ArrayList<SimpleFeature>(); FeatureIterator<SimpleFeature> featureIterator = inBasins.features(); basinNum = inBasins.size(); SimpleFeatureType featureType = inBasins.getSchema(); int basinIdFieldIndex = featureType.indexOf(fBasinid); if (basinIdFieldIndex == -1) { throw new IllegalArgumentException( "The field of the basin id couldn't be found in the supplied basin data."); } if (fBasinlandcover != null) { usoFieldIndex = featureType.indexOf(fBasinlandcover); if (usoFieldIndex == -1) { throw new IllegalArgumentException( "The field of the soil type (usofield) couldn't be found in the supplied basin data."); } } basinid2BasinindexMap = new HashMap<Integer, Integer>(); basinindex2BasinidMap = new HashMap<Integer, Integer>(); pm.beginTask("Read basins data.", inBasins.size()); int index = 0; Abasin = new double[basinNum]; while (featureIterator.hasNext()) { pm.worked(1); SimpleFeature feature = featureIterator.next(); basinsFeatures.add(feature); basinid2BasinindexMap.put(((Number) feature.getAttribute(basinIdFieldIndex)).intValue(), index); basinindex2BasinidMap.put(index, ((Number) feature.getAttribute(basinIdFieldIndex)).intValue()); Geometry basinGeometry = (Geometry) feature.getDefaultGeometry(); Abasin[index] = basinGeometry.getArea() / 1000000.0; // area in km2 as the input // area for energetic and // altimetric bands index++; // read land cover if requested if (usoFieldIndex != -1) { if (usoList == null) { usoList = new ArrayList<Integer>(); } int uso = ((Number) feature.getAttribute(usoFieldIndex)).intValue(); usoList.add(uso); } } featureIterator.close(); pm.done(); } // get rain from scalar link double[] rain = new double[basinNum]; Set<Integer> basinIdSet = inRain.keySet(); pm.beginTask("Read rain data.", basinIdSet.size()); for (Integer basinId : basinIdSet) { pm.worked(1); Integer index = basinid2BasinindexMap.get(basinId); if (index == null) { continue; } double[] value = inRain.get(basinId); if (!isNovalue(value[0])) { rain[index] = value[0]; } else { rain[index] = 0.0; } } pm.done(); // get energy values from scalar link ([12][num_EI][basinNum]) 12 == // 0,1,2,3,4,5,5,4,3,2,1,0 ones at the beginning of the simulation if (EI == null) { EI = new double[12][num_EI][basinNum]; pm.beginTask("Read energy index data.", inEnergy.size()); for (EIEnergy energy : inEnergy) { pm.worked(1); int tempId = energy.basinId; Integer index = basinid2BasinindexMap.get(tempId); if (index == null) { // basinid2BasinindexMap.remove(tempId); continue; } int j = energy.energeticBandId; int k = energy.virtualMonth; int kInverse = 11 - k; EI[k][j][index] = energy.energyValue; EI[kInverse][j][index] = energy.energyValue; } pm.done(); } // get area bande fascie from scalar link ([num_ES][num_EI][basinNum]) ones at the // beginning of the simulation if (A == null) { A = new double[num_ES][num_EI][basinNum]; pm.beginTask("Read area per heigth and band data.", inAreas.size()); HashMap<Integer, HashMap<Integer, HashMap<Integer, Double>>> idbasinMap = new HashMap<Integer, HashMap<Integer, HashMap<Integer, Double>>>(); for (EIAreas area : inAreas) { int idBasin = area.basinId; HashMap<Integer, HashMap<Integer, Double>> idfasceMap = idbasinMap.get(idBasin); if (idfasceMap == null) { idfasceMap = new HashMap<Integer, HashMap<Integer, Double>>(); idbasinMap.put(idBasin, idfasceMap); } int idAltimetricBand = area.altimetricBandId; HashMap<Integer, Double> idbandeMap = idfasceMap.get(idAltimetricBand); if (idbandeMap == null) { idbandeMap = new HashMap<Integer, Double>(); idfasceMap.put(idAltimetricBand, idbandeMap); } int idEnergeticBand = area.energyBandId; double areaValue = area.areaValue; idbandeMap.put(idEnergeticBand, areaValue); pm.worked(1); } pm.done(); for (int i = 0; i < basinNum; i = i + 1) { Integer index = basinindex2BasinidMap.get(i); if (index == null) { basinid2BasinindexMap.remove(i); continue; } HashMap<Integer, HashMap<Integer, Double>> fasceMap = idbasinMap.get(index); for (int j = 0; j < num_ES; j++) { HashMap<Integer, Double> bandeMap = fasceMap.get(j); for (int k = 0; k < num_EI; k++) { A[j][k][i] = bandeMap.get(k); } } } } // get T (temperatures per basin per band) from scalar input link at each time step double[][] T = null; if (inTemp != null) { T = new double[basinNum][num_ES]; pm.beginTask("Read temperature data.", inTemp.size()); Set<Integer> basinIdsSet = inTemp.keySet(); for (Integer basinId : basinIdsSet) { pm.worked(1); Integer index = basinid2BasinindexMap.get(basinId); if (index == null) { // data for a basin that is not considered, ignore it continue; } double[] values = inTemp.get(basinId); T[index] = values; } pm.done(); } // get V (wind speed per basin per band) from scalar link at each time step double[][] V = null; if (inWind != null) { V = new double[basinNum][num_ES]; pm.beginTask("Read wind speed data.", inWind.size()); Set<Integer> basinIdsSet = inWind.keySet(); for (Integer basinId : basinIdsSet) { pm.worked(1); Integer index = basinid2BasinindexMap.get(basinId); if (index == null) { // data for a basin that is not considered, ignore it continue; } double[] values = inWind.get(basinId); V[index] = values; } } // get P (pressure per basin per band) from scalar link at each time step double[][] P = null; if (inPressure != null) { P = new double[basinNum][num_ES]; pm.beginTask("Read pressure data.", inPressure.size()); Set<Integer> basinIdsSet = inPressure.keySet(); for (Integer basinId : basinIdsSet) { pm.worked(1); Integer index = basinid2BasinindexMap.get(basinId); if (index == null) { // data for a basin that is not considered, ignore it continue; } double[] values = inPressure.get(basinId); P[index] = values; } pm.done(); } // get RH (relative humidity per basin per band) from scalar link at each time step double[][] RH = null; if (inRh != null) { RH = new double[basinNum][num_ES]; pm.beginTask("Read humidity data.", inRh.size()); Set<Integer> basinIdsSet = inRh.keySet(); for (Integer basinId : basinIdsSet) { pm.worked(1); Integer index = basinid2BasinindexMap.get(basinId); if (index == null) { // data for a basin that is not considered, ignore it continue; } double[] values = inRh.get(basinId); RH[index] = values; } pm.done(); } // get dtday (daily temperature range per basin per band) from scalar link at each time // step double[][] DTd = null; if (inDtday != null) { DTd = new double[basinNum][num_ES]; pm.beginTask("Read dtday data.", inDtday.size()); Set<Integer> basinIdsSet = inDtday.keySet(); for (Integer basinId : basinIdsSet) { pm.worked(1); Integer index = basinid2BasinindexMap.get(basinId); if (index == null) { // data for a basin that is not considered, ignore it continue; } double[] values = inDtday.get(basinId); DTd[index] = values; } pm.done(); } // get dtmonth (monthly temperature range per basin per band) from scalar link at each // time step double[][] DTm = null; if (inDtmonth != null) { DTm = new double[basinNum][num_ES]; pm.beginTask("Read dtday data.", inDtmonth.size()); Set<Integer> basinIdsSet = inDtmonth.keySet(); for (Integer basinId : basinIdsSet) { pm.worked(1); Integer index = basinid2BasinindexMap.get(basinId); if (index == null) { // data for a basin that is not considered, ignore it continue; } double[] values = inDtmonth.get(basinId); DTm[index] = values; } pm.done(); } /* * set the current time: day, month and hour */ DateTime currentDatetime = formatter.parseDateTime(tCurrent); int currentMonth = currentDatetime.getMonthOfYear(); int currentDay = currentDatetime.getDayOfMonth(); int currentMinute = currentDatetime.getMinuteOfDay(); double hour = currentMinute / 60.0; System.out.println("ora: " + hour); if (averageTemperature == null) { averageTemperature = new double[2 * basinNum]; } else { Arrays.fill(averageTemperature, 0.0); } /* * these have to be taken from initial values */ if (safePoint.SWE == null) { if (pInitsafepoint != null && new File(pInitsafepoint).exists()) { safePoint = getSafePointData(); } else { safePoint.SWE = new double[num_ES][num_EI][basinNum]; if (pInitswe == -9999.0) { pInitswe = 0.0; } for (int i = 0; i < basinNum; i++) { double sweTmp = pInitswe; if (usoList != null) { int usoTmp = usoList.get(i); if (usoTmp == pGlacierid) { sweTmp = GLACIER_SWE; } } for (int k = 0; k < num_ES; k++) { for (int j = 0; j < num_EI; j++) { safePoint.SWE[j][k][i] = sweTmp; } } } safePoint.U = new double[num_ES][num_EI][basinNum]; safePoint.SnAge = new double[num_ES][num_EI][basinNum]; safePoint.Ts = new double[num_ES][num_EI][basinNum]; } } // this has to be taken from a file, scalarreader // TODO add the input canopyLink for the canopy height for each altimetric band /* * if there is no canopy input matrix for the model create an empty canopy matrix for each elevation band and for each basin */ double[][] canopy = new double[num_ES][basinNum]; for (int i = 0; i < canopy.length; i++) { for (int j = 0; j < canopy[0].length; j++) { canopy[i][j] = pCanopyh; } } checkParametersAndRunEnergyBalance(rain, T, V, P, RH, currentMonth, currentDay, hour, Abasin, A, EI, DTd, DTm, canopy); }
From source file:org.jgrasstools.hortonmachine.modules.networktools.trento_p.net.NetworkCalibration.java
License:Open Source License
/** * Set the parameter throughout the Builder, * /* w ww .ja v a 2 s . c om*/ */ private NetworkCalibration(Builder builder) { this.dt = builder.dt; this.pm = builder.pm; this.celerityfactor1 = builder.celerityfactor1; this.discharge = builder.discharge; this.fillDegree = builder.fillDegree; this.tMax = builder.tMax; this.strBuilder = builder.strBuilder; this.tpMaxCalibration = builder.tpMaxCalibration; this.foundMaxrainTime = builder.foundMaxrainTime; if (builder.networkPipe != null) { this.networkPipes = builder.networkPipe; } else { pm.errorMessage(msg.message("trentoP.error.network")); throw new IllegalArgumentException("trentoP.error.network"); } if (builder.inRain != null) { this.inRain = builder.inRain; // create the rains array from the input. Set<Entry<DateTime, double[]>> rainSet = inRain.entrySet(); DateTime second = null; int l = rainSet.size(); rainData = new double[l][2]; int index = 0; for (Entry<DateTime, double[]> rainRecord : rainSet) { DateTime dateTime = rainRecord.getKey(); double[] values = rainRecord.getValue(); if (first == null) { first = dateTime; } else if (second == null && dt == null) { second = dateTime; } rainData[index][0] = index + 1; rainData[index][1] = values[0]; index++; } // Evaluate the time step, if it isn't passed as a parameter,as a difference between two // time. if (dt == null) { dt = abs(second.getMinuteOfDay() - first.getMinuteOfDay()); } // if the input has the date in a wrong order. if (dt <= 0) { pm.errorMessage(msg.message("trentoP.error.t")); throw new IllegalArgumentException(msg.message("trentoP.error.t")); } double tMaxApproximate = ModelsEngine.approximate2Multiple(tMax, dt); // initialize the output. nTime = (int) (tMaxApproximate / dt); lastTimeDischarge = createMatrix(); lastTimeFillDegree = createMatrix(); } else { pm.errorMessage(msg.message("trentoP.error.rainData ")); throw new IllegalArgumentException(msg.message("trentoP.error.rainData")); } }
From source file:org.jlucrum.realtime.generators.TickGenerator.java
License:Open Source License
private boolean timeout() { DateTimeZone timeZone = null;/*from w w w. ja va2s.co m*/ DateTime time = null; long startTickerTime = 0; long endTickerTime = 0; boolean toContinue = false; timeZone = DateTimeZone.forID(config.timeZone); startTickerTime = config.start_hour * 60 + config.start_minute; endTickerTime = config.end_hour * 60 + config.end_minute; try { time = new DateTime(timeZone); System.out.printf("Timezone:%s and week:%d - %d", timeZone.toString(), time.getDayOfWeek(), DateTimeConstants.SATURDAY); if (DateTimeConstants.SATURDAY == time.getDayOfWeek()) { long toSleep = 24 * 60 - time.getMinuteOfDay() + 24 * 60; System.out.printf("TickGenerator sleeps until Monday, because it is Saturday\n"); Thread.sleep(toSleep * 60 * 1000); toContinue = true; } else if (DateTimeConstants.SUNDAY == time.getDayOfWeek()) { long toSleep = 24 * 60 - time.getMinuteOfDay(); System.out.printf("TickGenerator sleeps until Monday, because it is Sunday\n"); Thread.sleep(toSleep * 60 * 1000); toContinue = true; } if (time.getMinuteOfDay() < startTickerTime) { long minutesToSleep = Math.abs(time.getMinuteOfDay() - startTickerTime); System.out.printf("Sleeping (%d) minutes ... Starting 1 at:%d:%d\n", minutesToSleep, config.start_hour, config.start_minute); Thread.sleep(minutesToSleep * 60 * 1000); toContinue = true; } else if (time.getMinuteOfDay() > endTickerTime) { long minutesToSleep = 24 * 60 - time.getMinuteOfDay(); minutesToSleep += startTickerTime; System.out.printf("Sleeping (%d) minutes ... Starting 2 at:%d:%d\n", minutesToSleep, config.start_hour, config.start_minute); Thread.sleep(minutesToSleep * 60 * 1000); toContinue = true; } } catch (InterruptedException ex) { Logger.getLogger(TickGenerator.class.getName()).log(Level.SEVERE, null, ex); } return toContinue; }
From source file:org.openvpms.web.workspace.admin.calendar.CalendarTableModel.java
License:Open Source License
/** * Returns the number of rows spanned by an event, starting from the specified cell. * * @param event the event//w ww . j a v a 2 s . c o m * @param column the cell column * @param row the cell row * @return the number of spanned rows */ public int getRows(PropertySet event, int column, int row) { Date columnDate = grid.getDatetime(column - 1, row); Date end = event.getDate(ScheduleEvent.ACT_END_TIME); int lastSlot; if (DateRules.dateEquals(columnDate, end)) { DateTime endTime = new DateTime(end); int minutes = endTime.getMinuteOfDay(); int slotSize = grid.getSlotSize(); lastSlot = minutes / slotSize; if (minutes % slotSize != 0 && lastSlot < grid.getSlots()) { lastSlot++; } } else { lastSlot = grid.getSlots(); } return lastSlot - row; }
From source file:org.springframework.analytics.metrics.memory.InMemoryAggregateCounter.java
License:Apache License
synchronized long increment(long amount, DateTime dateTime) { int year = dateTime.getYear(); int month = dateTime.getMonthOfYear(); int day = dateTime.getDayOfYear(); int hour = dateTime.getHourOfDay(); int minute = dateTime.getMinuteOfDay(); long[] monthCounts = monthCountsByYear.get(year); long[] dayCounts = dayCountsByYear.get(year); if (monthCounts == null) { monthCounts = new long[12]; monthCountsByYear.put(year, monthCounts); dayCounts = new long[daysInYear(year)]; dayCountsByYear.put(year, dayCounts); }/*from w ww. j a v a2s. com*/ int countsByDayKey = year * 1000 + day; long[] hourCounts = hourCountsByDay.get(countsByDayKey); if (hourCounts == null) { hourCounts = new long[24]; hourCountsByDay.put(countsByDayKey, hourCounts); } long[] minuteCounts = minuteCountsByDay.get(countsByDayKey); if (minuteCounts == null) { minuteCounts = new long[60 * 24]; minuteCountsByDay.put(countsByDayKey, minuteCounts); } minuteCounts[minute] += amount; monthCounts[month - 1] += amount; dayCounts[day - 1] += amount; hourCounts[hour] += amount; return increment(amount); }