List of usage examples for java.util Calendar clone
@Override
public Object clone()
From source file:de.ribeiro.android.gso.dataclasses.Pager.java
/** * @param weekData/*from w ww . jav a2 s . c om*/ * @param currentWeek * @return * @author Tobias Janssen * <p/> * Erstellt den berschriften String */ private String createWeekHeader(WeekData weekData, Calendar currentWeek) { int firstDay = currentWeek.get(Calendar.DAY_OF_MONTH); Calendar cal = (Calendar) currentWeek.clone(); // den aktuellen Wochentag abrufen int currentDayOfWeek = cal.get(Calendar.DAY_OF_WEEK); // den currentDay auf Montag setzten if (currentDayOfWeek < 6) { // 1000*60*60*24 = 1 Tag! cal.setTimeInMillis(cal.getTimeInMillis() + (1000 * 60 * 60 * 24 * (6 - currentDayOfWeek))); } int lastDay = cal.get(Calendar.DAY_OF_MONTH); return firstDay + "." + (currentWeek.get(Calendar.MONTH) + 1) + " - " + lastDay + "." + (cal.get(Calendar.MONTH) + 1) + "." + cal.get(Calendar.YEAR); }
From source file:org.mule.modules.salesforce.SalesforceModule.java
/** * Retrieves the list of individual records that have been deleted between the range of now to the duration before now. * <p/>// www . j a v a2 s . c o m * {@sample.xml ../../../doc/mule-module-sfdc.xml.sample sfdc:get-deleted} * * @param type Object type. The specified value must be a valid object for your organization. * @param duration The amount of time in minutes before now for which to return records from. * @return {@link GetDeletedResult} * @throws Exception * @api.doc <a href="http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_getdeleted.htm">getDeleted()</a> * @since 4.2 */ @Processor @InvalidateConnectionOn(exception = SoapConnection.SessionTimedOutException.class) public GetDeletedResult getDeleted(@Placement(group = "Information") @FriendlyName("sObject Type") String type, @Placement(group = "Information") int duration) throws Exception { Calendar serverTime = connection.getServerTimestamp().getTimestamp(); Calendar startTime = (Calendar) serverTime.clone(); Calendar endTime = (Calendar) serverTime.clone(); endTime.add(Calendar.MINUTE, duration); return getDeletedRange(type, startTime, endTime); }
From source file:org.mule.modules.salesforce.SalesforceModule.java
/** * Retrieves the list of individual records that have been updated between the range of now to the duration before now. * <p/>/*from ww w . ja v a2s.co m*/ * <p/> * {@sample.xml ../../../doc/mule-module-sfdc.xml.sample sfdc:get-updated} * * @param type Object type. The specified value must be a valid object for your organization. * @param duration The amount of time in minutes before now for which to return records from. * @return {@link GetDeletedResult} * @throws Exception * @api.doc <a href="http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_getupdated.htm">getUpdated()</a> */ @Processor @InvalidateConnectionOn(exception = SoapConnection.SessionTimedOutException.class) public GetUpdatedResult getUpdated(@Placement(group = "Information") @FriendlyName("sObject Type") String type, @Placement(group = "Information") int duration) throws Exception { Calendar serverTime = connection.getServerTimestamp().getTimestamp(); Calendar startTime = (Calendar) serverTime.clone(); Calendar endTime = (Calendar) serverTime.clone(); endTime.add(Calendar.MINUTE, duration); return getUpdatedRange(type, startTime, endTime); }
From source file:it.govpay.core.business.Pagamento.java
public String verificaTransazioniPendenti() throws GovPayException { GpContext ctx = GpThreadLocal.get(); ctx.log("pendenti.avvio"); List<String> response = new ArrayList<String>(); try {// w w w. jav a 2s. c om StazioniBD stazioniBD = new StazioniBD(this); List<Stazione> lstStazioni = stazioniBD.getStazioni(); DominiBD dominiBD = new DominiBD(this); for (Stazione stazione : lstStazioni) { DominioFilter filter = dominiBD.newFilter(); filter.setCodStazione(stazione.getCodStazione()); List<Dominio> lstDomini = dominiBD.findAll(filter); Intermediario intermediario = stazione.getIntermediario(this); closeConnection(); ctx.log("pendenti.acquisizionelistaPendenti", stazione.getCodStazione()); log.debug("Recupero i pendenti [CodStazione: " + stazione.getCodStazione() + "]"); // Costruisco una mappa di tutti i pagamenti pendenti sul nodo // La chiave di lettura e' iuv@ccp NodoClient client = new NodoClient(intermediario, this); // Le pendenze per specifica durano 60 giorni. int finestra = 60; Calendar fineFinestra = Calendar.getInstance(); Calendar inizioFinestra = (Calendar) fineFinestra.clone(); inizioFinestra.add(Calendar.DATE, -finestra); Map<String, String> statiRptPendenti = acquisisciPendenti(client, intermediario, stazione, lstDomini, false, inizioFinestra, fineFinestra, 500); log.info("Identificate sul NodoSPC " + statiRptPendenti.size() + " RPT pendenti"); ctx.log("pendenti.listaPendentiOk", stazione.getCodStazione(), statiRptPendenti.size() + ""); // Ho acquisito tutti gli stati pendenti. // Tutte quelle in stato terminale, setupConnection(GpThreadLocal.get().getTransactionId()); RptBD rptBD = new RptBD(this); List<String> codDomini = new ArrayList<String>(); for (Dominio d : lstDomini) { codDomini.add(d.getCodDominio()); } List<Rpt> rpts = rptBD.getRptPendenti(codDomini); log.info("Identificate su GovPay " + rpts.size() + " transazioni pendenti"); ctx.log("pendenti.listaPendentiGovPayOk", rpts.size() + ""); // Scorro le transazioni. Se non risulta pendente sul nodo (quindi non e' pendente) la mando in aggiornamento. Date mezzorafa = new Date(new Date().getTime() - (30 * 60 * 1000)); for (Rpt rpt : rpts) { // WORKAROUND CONCORRENZA CON INVIO RT DAL NODO // SKIPPO LE RPT PENDENTI CREATE MENO DI MEZZ'ORA FA if (rpt.getDataMsgRichiesta().after(mezzorafa)) { log.debug("Rpt recente [CodMsgRichiesta: " + rpt.getCodMsgRichiesta() + "]: aggiornamento non necessario"); continue; } String stato = statiRptPendenti.get(rpt.getIuv() + "@" + rpt.getCcp()); if (stato != null) { log.debug("Rpt confermata pendente dal nodo [CodMsgRichiesta: " + rpt.getCodMsgRichiesta() + "]: stato " + stato); ctx.log("pendenti.confermaPendente", rpt.getCodDominio(), rpt.getIuv(), rpt.getCcp(), stato); StatoRpt statoRpt = StatoRpt.toEnum(stato); if (!rpt.getStato().equals(statoRpt)) { response.add("[" + rpt.getCodDominio() + " " + rpt.getIuv() + " " + rpt.getCcp() + "]# Aggiornamento in stato " + stato.toString()); rptBD.updateRpt(rpt.getId(), statoRpt, null, null, null); } } else { log.debug("Rpt non pendente sul nodo [CodMsgRichiesta: " + rpt.getCodMsgRichiesta() + "]"); ctx.log("pendenti.confermaNonPendente", rpt.getCodDominio(), rpt.getIuv(), rpt.getCcp()); // Accedo alle entita che serviranno in seguito prima di chiudere la connessione; rpt.getStazione(this).getIntermediario(this); try { RptUtils.aggiornaRptDaNpD(client, rpt, this); } catch (NdpException e) { ctx.log("pendenti.rptAggiornataKo", rpt.getCodDominio(), rpt.getIuv(), rpt.getCcp(), e.getFault().getFaultString()); log.warn("Errore durante l'aggiornamento della RPT: " + e.getFault().getFaultString()); continue; } catch (Exception e) { ctx.log("pendenti.rptAggiornataFail", rpt.getCodDominio(), rpt.getIuv(), rpt.getCcp(), e.getMessage()); log.warn("Errore durante l'aggiornamento della RPT", e); continue; } if (rpt.getStato().equals(StatoRpt.RPT_ATTIVATA)) { ctx.log("pendenti.rptAttivata", rpt.getCodDominio(), rpt.getIuv(), rpt.getCcp()); log.info("[" + rpt.getCodDominio() + "][" + rpt.getIuv() + "][" + rpt.getCcp() + "]#Rpt in stato " + rpt.getStato().toString() + ". Avviata rispedizione al Nodo."); } else { ctx.log("pendenti.rptAggiornata", rpt.getCodDominio(), rpt.getIuv(), rpt.getCcp(), rpt.getStato().toString()); log.info("[" + rpt.getCodDominio() + "][" + rpt.getIuv() + "][" + rpt.getCcp() + "]#Rpt pendente aggiornata in stato " + rpt.getStato().toString()); response.add("[" + rpt.getCodDominio() + " " + rpt.getIuv() + " " + rpt.getCcp() + "]# Aggiornamento in stato " + rpt.getStato().toString()); } } } } } catch (Exception e) { log.warn("Fallito aggiornamento pendenti", e); throw new GovPayException(EsitoOperazione.INTERNAL, e); } if (response.isEmpty()) { return "Acquisizione completata#Nessun pagamento pendente."; } else { return StringUtils.join(response, "|"); } }
From source file:org.apache.oozie.coord.CoordELFunctions.java
/** * Find the current instance based on effectiveTime (i.e Action_Creation_Time or Action_Start_Time) * * @return current instance i.e. current(0) returns null if effectiveTime is earlier than Initial Instance time of * the dataset./*from w w w .j a va2s.c o m*/ */ private static Calendar getCurrentInstance_old(Date effectiveTime, int instanceCount[], ELEvaluator eval) { Date datasetInitialInstance = getInitialInstance(eval); TimeUnit dsTimeUnit = getDSTimeUnit(eval); TimeZone dsTZ = getDatasetTZ(eval); int dsFreq = getDSFrequency(eval); // Convert Date to Calendar for corresponding TZ Calendar current = Calendar.getInstance(); current.setTime(datasetInitialInstance); current.setTimeZone(dsTZ); Calendar calEffectiveTime = Calendar.getInstance(); calEffectiveTime.setTime(effectiveTime); calEffectiveTime.setTimeZone(dsTZ); if (instanceCount == null) { // caller doesn't care about this value instanceCount = new int[1]; } instanceCount[0] = 0; if (current.compareTo(calEffectiveTime) > 0) { return null; } Calendar origCurrent = (Calendar) current.clone(); while (current.compareTo(calEffectiveTime) <= 0) { current = (Calendar) origCurrent.clone(); instanceCount[0]++; current.add(dsTimeUnit.getCalendarUnit(), instanceCount[0] * dsFreq); } instanceCount[0]--; current = (Calendar) origCurrent.clone(); current.add(dsTimeUnit.getCalendarUnit(), instanceCount[0] * dsFreq); return current; }
From source file:com.alkacon.opencms.calendar.CmsCalendarMonthBean.java
/** * Returns the days of a month to display in a matrix, depending on the start day of the week.<p> * //from w w w . j a v a 2s . c o m * The month matrix starts with index "1" and uses 7 columns per row to display one week in a row. * The value returns null if no date should be shown at the current index position.<p> * * @param year the year of the month to display * @param month the month to display * @param calendarLocale the Locale for the calendar to determine the start day of the week * @return the days of a month to display in a matrix, depending on the start day of the week */ public Map getMonthDaysMatrix(int year, int month, Locale calendarLocale) { Map monthDays = new TreeMap(); Calendar startDay = new GregorianCalendar(year, month, 1); Calendar runDay = startDay; int index = 1; // calculate the start day of the week Calendar calendar = new GregorianCalendar(calendarLocale); int weekStart = calendar.getFirstDayOfWeek(); // create empty indexes before the first day of the month while (runDay.get(Calendar.DAY_OF_WEEK) != weekStart) { monthDays.put(new Integer(index), null); index++; if (weekStart == Calendar.SATURDAY) { weekStart = Calendar.SUNDAY; } else { weekStart++; } } // create the indexes for the month dates while (true) { monthDays.put(new Integer(index), runDay.clone()); // increase day to next day runDay.roll(Calendar.DAY_OF_MONTH, true); index++; if (runDay.get(Calendar.DAY_OF_MONTH) == 1) { // runDay has switched to the next month, stop loop break; } } // create empty indexes after the last day of the month int rest = (index - 1) % 7; if (rest > 0) { rest = 7 - rest; } for (int i = 0; i < rest; i++) { monthDays.put(new Integer(index), null); index++; } return monthDays; }
From source file:com.china317.gmmp.gmmp_report_analysis.service.imp.DgmAnalysisImp.java
public long getIllegalParkingTime(Date zeroSpeedBegin) { long time = 0; Calendar now = Calendar.getInstance(); Calendar start_point = (Calendar) now.clone(); if (now.get(Calendar.HOUR_OF_DAY) < 22) { start_point.add(Calendar.DAY_OF_MONTH, -1); }/*from w ww . j a va 2s. c o m*/ start_point.set(Calendar.HOUR_OF_DAY, 22); start_point.set(Calendar.MINUTE, 0); start_point.set(Calendar.SECOND, 0); Calendar end_point = (Calendar) start_point.clone(); end_point.add(Calendar.HOUR_OF_DAY, 10); if (now.getTimeInMillis() > start_point.getTimeInMillis() && now.getTimeInMillis() < end_point.getTimeInMillis()) { if (zeroSpeedBegin.getTime() > start_point.getTimeInMillis() && zeroSpeedBegin.getTime() < end_point.getTimeInMillis()) { time = now.getTimeInMillis() - zeroSpeedBegin.getTime(); } else if (zeroSpeedBegin.getTime() <= start_point.getTimeInMillis()) { time = now.getTimeInMillis() - start_point.getTimeInMillis(); } else { //zeroSpeedBegin.getTime()>=end_point.getTimeInMillis() } } else if (now.getTimeInMillis() < start_point.getTimeInMillis()) { } else { //now.getTimeInMillis()>=end_point.getTimeInMillis() if (zeroSpeedBegin.getTime() > start_point.getTimeInMillis() && zeroSpeedBegin.getTime() < end_point.getTimeInMillis()) { time = end_point.getTimeInMillis() - zeroSpeedBegin.getTime(); } else if (zeroSpeedBegin.getTime() <= start_point.getTimeInMillis()) { time = end_point.getTimeInMillis() - start_point.getTimeInMillis(); } else { //zeroSpeedBegin.getTime()>=end_point.getTimeInMillis() } } Calendar end_point_yest = (Calendar) end_point.clone(); end_point_yest.add(Calendar.DAY_OF_MONTH, -1); long tempTime = end_point_yest.getTimeInMillis() - zeroSpeedBegin.getTime(); //time = Math.max(time, tempTime>_1Hour*8?_1Hour*8:tempTime); time += tempTime > _1Hour * 8 ? _1Hour * 8 : (tempTime < 0 ? 0 : tempTime); return time; }
From source file:org.openmrs.module.diabetesmanagement.SimulationModelAIDA.java
/** * Runs a 72-hour simulation in steps of size 'h' * hour (using the Euler method of solving * differential equations numerically). Writes results of the third day run into the result * variables (every 15 minutes).// w ww . j a v a 2s . c o m */ public void runSimulation() { if (AG == null || RTG == null || CCR == null || sh == null || sp == null || insulin1ParamS == null || insulin1ParamA == null || insulin1ParamB == null || insulin2ParamS == null || insulin2ParamA == null || insulin2ParamB == null) throw new NullPointerException("All patient and insulin parameters must be set before running!"); // Some default values if (G == null) G = 0.0; if (I == null) I = 0.0; Integer Ie = (int) (sh * I / Ibasal); // effective insulin level Double Ia = 0.0; // active insulin pool Double Gin = 0.0; // glucose input via the gut wall Double Gout = 0.0; // overall rate of peripheral and insulin-independent glucose utilisation Double Ggut = 0.0; // amount of glucose in the gut Double Gempt = 0.0; // gastric emptying rate Double Gren = 0.0; // renal glucose excretion // Double Iss = 0.0; // steady state insulin profile Double Iass = 0.0; // steady state active insulin profile Double Iabs = 0.0, Iabs1, Iabs2; // insulin absorbtion rate Double Ieq = 0.0; // insulin level in equilibrium with Ia,ss(t) Double NHGB; // net hepatic insulin balance Double D1 = 0.0, D2 = 0.0; // insulin doses Double T50_1 = 0.0, T50_2 = 0.0; // time at which 50% of the insulin dose D1/D2 has been // absorbed Double Ch = 0.0; // (mmol) glucose equivalent carbohydrate Double Tmaxge = 0.0, Tascge = 0.5, Tdesge = 0.5; // durations of gastric emptying curve // branches Double t_meal_double, t_insulin_double; // Double conversions of t_meal, t_insulinshort, // t_insulinlong Integer t_meal = 0, t_insulin1 = 0, t_insulin2 = 0; // times elapsed from the last // meal/injection // Previous Ia values for Ieq calculation Double[] Ia24 = new Double[iterations]; Double[] Ia48 = new Double[iterations]; for (int i = 0; i < iterations; i++) { Ia24[i] = 0.0; Ia48[i] = 0.0; } // Initialize calendar and save the date Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); // needed to be in sync with meals and injections Calendar ref = (Calendar) cal.clone(); // backup calendar for resetting // Reset result sets resultGlucose = new HashMap<Date, Double>(); resultInsulin = new HashMap<Date, Double>(); // Outer loop: Run a 3 day simulation to reach steady state, saving the results from the // third run for (int i = 0; i < 3; ++i) { cal.setTime(ref.getTime()); // reset calendar after each run // Inner loop: 24 hours in 24/h+1 steps for (int j = 0; j <= iterations; ++j) { // Look for an insulin injection at the given time // (4) T50^s = a * D + b if (insulinInjections1 != null && insulinInjections1.get(cal.getTime()) != null) { t_insulin1 = 0; D1 = insulinInjections1.get(cal.getTime()); T50_1 = insulin1ParamA * D1 + insulin1ParamB; } else if (D1 > 0.0) t_insulin1++; if (insulinInjections2 != null && insulinInjections2.get(cal.getTime()) != null) { t_insulin2 = 0; D2 = insulinInjections2.get(cal.getTime()); T50_2 = insulin2ParamA * D2 + insulin2ParamB; } else if (D2 > 0.0) t_insulin2++; // Save Ia values from the first two runs to the arrays if (i == 0) Ia48[i] = Ia; else if (i == 1) Ia24[i] = Ia; // (3) Iabs(t) = (s * t^s * T50^s * D) / (t * [T50^s + t^s]^2) Iabs1 = 0.0; Iabs2 = 0.0; if (t_insulin1 > 0) { t_insulin_double = t_insulin1 * h; Iabs1 = (insulin1ParamS * Math.pow(t_insulin_double, insulin1ParamS) * T50_1 * D1) / (t_insulin_double * Math.pow(T50_1 + Math.pow(t_insulin_double, insulin1ParamS), 2.0)); } if (t_insulin2 > 0) { t_insulin_double = t_insulin2 * h; Iabs2 = (insulin2ParamS * Math.pow(t_insulin_double, insulin2ParamS) * T50_2 * D2) / (t_insulin_double * Math.pow(T50_2 + Math.pow(t_insulin_double, insulin2ParamS), 2.0)); } Iabs = Iabs1 + Iabs2; // (5a) Iss(t) = I(t) + I(t + 24) + I(t + 48) // Iss = 3.0 * I; // (5b) Ia,ss(t) = Ia(t) + Ia(t + 24) + Ia(t + 48) switch (i) { case 0: Iass = 3.0 * Ia; case 1: Iass = 2.0 * Ia + Ia48[i]; case 2: Iass = Ia + Ia24[i] + Ia48[i]; default: Iass = 0.0; } // (6) Ieq(t) = k2 * Ia,ss(t) / k1 Ieq = k2 * Iass / k1; // Setting NHGB from NHGBtable, based on the effective insulin (Ie) and arterial // glucose (AG) levels if (Ie >= 0) { if (AG <= 1.1) NHGB = NHGBtable[Ie][0]; else if (AG >= 4.4) NHGB = NHGBtable[Ie][2]; else NHGB = NHGBtable[Ie][1]; } else NHGB = null; // Glucose utilization (Gout) by the central nervous system (insulin-independent) // (8) Gout(G,I#eq) = (G * (c * Sp * I#eq + GI) * (Km + GX)) / (GX * (Km + G)) Gout = (G * ((c * weight) * sp * Ieq + (GI * weight)) * (Km + GX)) / (GX * (Km + G)); // Look for a meal at the given time if (meals != null && meals.get(cal.getTime()) != null) { // Convert the carbs from g to mmol (mmol = g / 180 * 10^3, assuming the molar // weight of glucose is 180) Ch = meals.get(cal.getTime()) / 180.0 * 1000.0; t_meal = 0; // (11) Tascge = Tdesge = Ch / Vmaxge (when Ch <= Chcrit (~10g))* // * Original equation (11) (Tascge = Tdesge = 2 * Ch / Vmaxge) by Lehmann, // Deutsch has been corrected by Fernandez, Villasana // (12) Chcrit = ((Tascge + Tdesge) * Vmaxge) / 2 Double Chcrit = ((Tascge + Tdesge) * Vmaxge) / 2.0; if (Ch <= Chcrit) { Tascge = Ch / Vmaxge; Tdesge = Tascge; } else { Tascge = 0.5; Tdesge = 0.5; } // Duration of Vmaxge (Tmaxge) // (10) Tmaxge = (Ch - 1/2 * Vmaxge * 2(Tascge + Tdesge) / Vmaxge if (Ch > Chcrit) Tmaxge = (Ch - (0.5 * Vmaxge) * (2.0 * (Tascge + Tdesge))) / Vmaxge; else Tmaxge = 0.0; } else if (Ch > 0.0) t_meal++; // (13) Gastric emptying (Gempt) t_meal_double = t_meal * h; if (t_meal_double < Tascge) Gempt = (Vmaxge / Tascge) * t_meal_double; else if (Tascge <= t_meal_double && t_meal_double <= Tascge + Tmaxge) Gempt = Vmaxge; else if (Tascge + Tmaxge <= t_meal_double && t_meal_double < Tascge + Tmaxge + Tdesge) Gempt = Vmaxge - (Vmaxge / Tdesge) * (t_meal_double - Tascge - Tmaxge); else Gempt = 0.0; // (9) d(Ggut)/dt = Gempt - kgabs * Ggut Ggut += h * (Gempt - kgabs * Ggut); if (Ggut < 0.0) Ggut = 0.0; // Glucose input (Gin) via the gut wall // (14) Gin = kgabs * Ggut Gin = kgabs * Ggut; // Renal glucose excretion (if above RTG) // (15a) Gren = CCR * (G - RTG)(if G > RTG) // (15b) Gren = 0 (else) // CCR: (ml/min) ==> CCR * 60 / 1000 ==> (l/h) if (G > RTG) Gren = (CCR * 60.0 / 1000.0) * (G - RTG); else Gren = 0.0; // Change in plasma glucose concentration for this time period // (7) dG/dt = (Gin(t) + NHGB(t) - Gout(t) - Gren(t)) / Vg G += h * ((Gin + NHGB - Gout - Gren) / (Vg * weight)); if (G < 0.0) G = 0.0; // Change in plasma insulin concentration for this time period // (1) dI/dt = Iabs / Vi - ke * I I += h * ((Iabs * (Vi * weight)) - ke * I); if (I < 0.0) I = 0.0; // Build-up and deactivation of the 'active' insulin pool // (2) dIa/dt = (k1 * I) - (k2 * Ia) Ia += h * (k1 * I - k2 * Ia); // Effective insulin Ie = (int) (sh * I / Ibasal); if (Ie > 10) Ie = 10; // When reached a 15-min mark, add current G,I to result sets if ((cal.get(Calendar.MINUTE) == 00 || cal.get(Calendar.MINUTE) == 15 || cal.get(Calendar.MINUTE) == 30 || cal.get(Calendar.MINUTE) == 45) && i == 2) { resultGlucose.put(cal.getTime(), G); resultInsulin.put(cal.getTime(), I); if (log.isDebugEnabled()) { log.debug("(" + j + ") " + "G: " + G); log.debug("(" + j + ") " + "I/Ia/Ie: " + I + "/" + Ia + "/" + Ie); log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ") " + "Gout: " + Gout); log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ") " + "Gren: " + Gren); log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ") " + "NHGB: " + NHGB); // log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + // cal.get(Calendar.MINUTE) + ") " + "meal (t/Ch): " + t_meal_double + "/" + // Ch); // log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + // cal.get(Calendar.MINUTE) + ") " + "Tascge/Tmaxge/Tdesge: " + Tascge + "/" // + Tmaxge + "/" + Tdesge); log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ") " + "Gempt/Ggut/Gin: " + Gempt + "/" + Ggut + "/" + Gin); // log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + // cal.get(Calendar.MINUTE) + ") " + "h*Gempt: " + h * Gempt); // log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + // cal.get(Calendar.MINUTE) + ") " + "path: " + path); log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ") " + "Iass: " + Iass); log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ") " + "short (s/a/b/t/T50/D): " + insulin1ParamS + "/" + insulin1ParamA + "/" + insulin1ParamB + "/" + t_insulin1 + "/" + T50_1 + "/" + D1); log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ") " + "long (s/a/b/t/T50/D): " + insulin2ParamS + "/" + insulin2ParamA + "/" + insulin2ParamB + "/" + t_insulin2 + "/" + T50_2 + "/" + D2); log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ") " + "Iabs: " + Iabs); log.debug("(" + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ") " + "Ieq: " + Ieq); log.debug(""); } } // Set 'cal' one step forward (fraction of an hour defined in 'calStep') cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE) + calStep, 0); } } }
From source file:org.kuali.mobility.events.controllers.CalendarController.java
@RequestMapping(value = "/month", method = RequestMethod.GET) public String month(HttpServletRequest request, Model uiModel, @RequestParam(required = false) String date) { User user = (User) request.getSession().getAttribute(Constants.KME_USER_KEY); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat my = new SimpleDateFormat("yyyyMM"); Calendar selectedDate = Calendar.getInstance(); try {/*from ww w . j av a 2 s. co m*/ if (date != null) { selectedDate.setTime(my.parse(date)); } } catch (ParseException e) { } try { Filter filter = (Filter) request.getSession().getAttribute("calendar.event.filterId"); MonthViewEvents monthEvents = calendarEventOAuthService.retrieveMonthEvents(user.getUserId(), selectedDate.getTime(), filter != null ? filter.getFilterId() : null); uiModel.addAttribute("viewData", monthEvents.getViewData()); uiModel.addAttribute("appData", monthEvents.getAppData()); int days = selectedDate.getActualMaximum(Calendar.DATE); Calendar startDate = (Calendar) selectedDate.clone(); startDate.set(Calendar.DATE, selectedDate.getActualMinimum(Calendar.DATE)); days += startDate.get(Calendar.DAY_OF_WEEK) - 1; Calendar endDate = (Calendar) selectedDate.clone(); endDate.set(Calendar.DATE, selectedDate.getActualMaximum(Calendar.DATE)); days += 7 - endDate.get(Calendar.DAY_OF_WEEK); startDate.set(Calendar.DAY_OF_WEEK, 1); Map<String, MobileDayOfMonth> daysInMonth = new LinkedHashMap<String, MobileDayOfMonth>(); uiModel.addAttribute("selectedDate", sdf.format(selectedDate.getTime())); for (int i = 0; i < days; i++) { MobileDayOfMonth mobileDayOfMonth = new MobileDayOfMonth(startDate.get(Calendar.DATE)); mobileDayOfMonth.setCurrentMonth(startDate.get(Calendar.MONTH) == selectedDate.get(Calendar.MONTH)); if (!mobileDayOfMonth.isCurrentMonth()) { mobileDayOfMonth.setBeforeCurrentMonth( startDate.get(Calendar.MONTH) < selectedDate.get(Calendar.MONTH)); } mobileDayOfMonth.setMonthYear(my.format(startDate.getTime())); mobileDayOfMonth.setDayOfWeek(startDate.get(Calendar.DAY_OF_WEEK)); daysInMonth.put(sdf.format(startDate.getTime()), mobileDayOfMonth); startDate.add(Calendar.DATE, 1); } for (Iterator iterator = monthEvents.getEvents().entrySet().iterator(); iterator.hasNext();) { Map.Entry<String, List<CalendarViewEvent>> entry = (Map.Entry<String, List<CalendarViewEvent>>) iterator .next(); MobileDayOfMonth dayInMonth = daysInMonth.get(entry.getKey()); dayInMonth.setHasEvents(true); dayInMonth.setEvents(entry.getValue()); } uiModel.addAttribute("events", daysInMonth); Calendar previousCalendar = (Calendar) selectedDate.clone(); previousCalendar.set(Calendar.DATE, 1); previousCalendar.getTime(); previousCalendar.add(Calendar.MONTH, -1); Calendar nextCalendar = (Calendar) selectedDate.clone(); nextCalendar.set(Calendar.DATE, 1); nextCalendar.getTime(); nextCalendar.add(Calendar.MONTH, 1); uiModel.addAttribute("previousMonth", my.format(previousCalendar.getTime())); uiModel.addAttribute("nextMonth", my.format(nextCalendar.getTime())); uiModel.addAttribute("monthYear", my.format(selectedDate.getTime())); uiModel.addAttribute("today", sdf.format(new Date())); uiModel.addAttribute("filter", filter); } catch (PageLevelException pageLevelException) { uiModel.addAttribute("message", pageLevelException.getMessage()); return "calendar/message"; } return "calendar/month"; }
From source file:com.alkacon.opencms.calendar.CmsCalendarDisplay.java
/** * Returns the next time range to show calendar entries for.<p> * Used for the navigation./*from ww w . j a va2s . com*/ * * @param actual the actual date from which the next time range should be calculated * @param type the type of period * @return a date for which a list of calendar entries should be shown */ public Calendar getNextPeriod(Calendar actual, int type) { Calendar cal = (Calendar) actual.clone(); switch (type) { case PERIOD_DAY: cal.add(Calendar.DAY_OF_YEAR, 1); break; case PERIOD_MONTH: cal.add(Calendar.MONTH, 1); break; case PERIOD_WEEK: cal.add(Calendar.WEEK_OF_YEAR, 1); break; case PERIOD_YEAR: cal.add(Calendar.YEAR, 1); break; default: break; } return cal; }