List of usage examples for java.util Calendar HOUR
int HOUR
To view the source code for java.util Calendar HOUR.
Click Source Link
get
and set
indicating the hour of the morning or afternoon. From source file:DateUtils.java
/** * Parse date time value from given string resolving any functions or formulas * the string can contain. This method can be therefore used if the passed * string contains string representation date, time or timestamp or a formula * such as now + 3h - 1m + 4d. /*from w w w .j a va 2 s . c om*/ * * @param strValue - string representation of date or date function * @param iDateType - date type code, one of the DATE_TYPE_XXX constants * @param stored - flag if Date should be parsed using format used for * storage or for display * @return Timestamp - parsed date or null if date was null * @throws OSSInvalidDataException - error during parsing */ public static Timestamp parseDateTime(String strValue, int iDateType, boolean stored) { Timestamp tsReturn = null; Calendar workCal = GregorianCalendar.getInstance(); if (strValue != null && strValue.length() > 0) { strValue = strValue.trim(); if (strValue.startsWith(CURRENT_DATE_CODE)) { strValue = strValue.replaceAll("[ ]", ""); // If the user specified "UseCurrent", then substitute the // current date/time in the value workCal.setTime(new Date()); // Log.getInstance().debug("Parsing current date " + strValue); // Parse the date math int iBeginIndex = CURRENT_DATE_CODE.length(); int iMaxLength = strValue.length(); int iSign = 1; int iNumberIndex; int iValue; char cChar = ' '; while (iBeginIndex < iMaxLength) { // This has to be sign if (strValue.charAt(iBeginIndex) == '+') { iSign = 1; } else if (strValue.charAt(iBeginIndex) == '-') { iSign = -1; } else { // Incorrect String throw new RuntimeException("Date function is in incorrect format: " + strValue + " at " + strValue.substring(iBeginIndex)); } iBeginIndex++; // Now we have to have number iNumberIndex = iBeginIndex; while (((iBeginIndex == iNumberIndex) || Character.isDigit(cChar)) && (iBeginIndex < iMaxLength)) { cChar = strValue.charAt(iBeginIndex++); } // We have to go one back because we should stop on modifier (e.g 1m) iBeginIndex--; try { iValue = Integer.parseInt(strValue.substring(iNumberIndex, iBeginIndex)); } catch (NumberFormatException nmeExc) { // Incorrect String throw new RuntimeException("Date function is in incorrect format: " + strValue + " at " + strValue.substring(iNumberIndex)); } // This has to be modifier: y - year, M - month, w - week, // d - day, h - hour, m - minute, s - second cChar = strValue.charAt(iBeginIndex); switch (cChar) { case (YEAR_CODE): { if (iDateType == DATE_TYPE_TIME) { throw new RuntimeException( "Date function is in incorrect format: " + "used YEAR modifier for TIME type"); } workCal.add(Calendar.YEAR, iSign * iValue); break; } case (MONTH_CODE): { if (iDateType == DATE_TYPE_TIME) { throw new RuntimeException( "Date function is in incorrect format: " + "used MONTH modifier for TIME type"); } workCal.add(Calendar.MONTH, iSign * iValue); break; } case (WEEK_CODE): { if (iDateType == DATE_TYPE_TIME) { throw new RuntimeException( "Date function is in incorrect format: " + "used WEEK modifier for TIME type"); } workCal.add(Calendar.WEEK_OF_YEAR, iSign * iValue); break; } case (DAY_CODE): { if (iDateType == DATE_TYPE_TIME) { throw new RuntimeException( "Date function is in incorrect format: " + "used DAY modifier for TIME type"); } workCal.add(Calendar.DATE, iSign * iValue); break; } case (HOUR_CODE): { if (iDateType == DATE_TYPE_DATE) { throw new RuntimeException( "Date function is in incorrect format: " + "used HOUR modifier for DATE type"); } workCal.add(Calendar.HOUR, iSign * iValue); break; } case (MINUTE_CODE): { if (iDateType == DATE_TYPE_DATE) { throw new RuntimeException("Date function is in incorrect format: " + "used MINUTE modifier for DATE type"); } workCal.add(Calendar.MINUTE, iSign * iValue); break; } case (SECOND_CODE): { if (iDateType == DATE_TYPE_DATE) { throw new RuntimeException("Date function is in incorrect format: " + "used SECOND modifier for DATE type"); } workCal.add(Calendar.SECOND, iSign * iValue); break; } default: { // Incorrect String throw new RuntimeException("Date function is in incorrect format: " + strValue + " at " + strValue.substring(iBeginIndex)); } } iBeginIndex++; } tsReturn = new Timestamp(workCal.getTimeInMillis()); } else { try { if (stored) { switch (iDateType) { case (DATE_TYPE_DATE): { tsReturn = new Timestamp(DATE_STORE_FORMAT.parse(strValue).getTime()); break; } case (DATE_TYPE_TIME): { tsReturn = new Timestamp(TIME_STORE_FORMAT.parse(strValue).getTime()); break; } case (DATE_TYPE_DATETIME): { tsReturn = new Timestamp(DATETIME_STORE_FORMAT.parse(strValue).getTime()); break; } default: { assert false : "Unknown date type " + iDateType; } } } else { switch (iDateType) { case (DATE_TYPE_DATE): { tsReturn = new Timestamp(DATE_FORMAT.parse(strValue).getTime()); break; } case (DATE_TYPE_TIME): { tsReturn = new Timestamp(TIME_FORMAT.parse(strValue).getTime()); break; } case (DATE_TYPE_DATETIME): { tsReturn = new Timestamp(DATETIME_FORMAT.parse(strValue).getTime()); break; } default: { assert false : "Unknown date type " + iDateType; } } } } catch (ParseException peExc) { throw new RuntimeException("Date is in incorrect format. Problems with parsing.", peExc); } } } return tsReturn; }
From source file:com.opendesign.utils.Day.java
public static long difference(Date startDate, Date endDate, int field) { long milliseconds1 = startDate.getTime(); long milliseconds2 = endDate.getTime(); long diff = milliseconds2 - milliseconds1; long diffSeconds = diff / 1000; long diffMinutes = diff / (60 * 1000); long diffHours = diff / (60 * 60 * 1000); long diffDays = diff / (24 * 60 * 60 * 1000); if (Calendar.HOUR == field) { return diffHours; } else if (Calendar.MINUTE == field) { return diffMinutes; } else if (Calendar.SECOND == field) { return diffSeconds; } else {//from w w w. ja va 2s. c o m return diffDays; } }
From source file:DateUtils.java
/** * Parse date time value from given string resolving any functions or formulas * the string can contain. This method can be therefore used if the passed * string contains string representation date, time or timestamp or a formula * such as now + 3h - 1m + 4d. //from w w w . j a v a2 s . c o m * * @param strValue - string representation of date or date function * @param iDateType - date type code, one of the DATE_TYPE_XXX constants * @param stored - flag if Date should be parsed using format used for * storage or for display * @return Timestamp - parsed date or null if date was null * @throws OSSInvalidDataException - error during parsing */ public static Timestamp parseDateTime(String strValue, int iDateType, boolean stored) throws Exception { Timestamp tsReturn = null; Calendar workCal = GregorianCalendar.getInstance(); if (strValue != null && strValue.length() > 0) { strValue = strValue.trim(); if (strValue.startsWith(CURRENT_DATE_CODE)) { strValue = strValue.replaceAll("[ ]", ""); // If the user specified "UseCurrent", then substitute the // current date/time in the value workCal.setTime(new Date()); // Log.getInstance().debug("Parsing current date " + strValue); // Parse the date math int iBeginIndex = CURRENT_DATE_CODE.length(); int iMaxLength = strValue.length(); int iSign = 1; int iNumberIndex; int iValue; char cChar = ' '; while (iBeginIndex < iMaxLength) { // This has to be sign if (strValue.charAt(iBeginIndex) == '+') { iSign = 1; } else if (strValue.charAt(iBeginIndex) == '-') { iSign = -1; } else { // Incorrect String throw new Exception("Date function is in incorrect format: " + strValue + " at " + strValue.substring(iBeginIndex)); } iBeginIndex++; // Now we have to have number iNumberIndex = iBeginIndex; while (((iBeginIndex == iNumberIndex) || Character.isDigit(cChar)) && (iBeginIndex < iMaxLength)) { cChar = strValue.charAt(iBeginIndex++); } // We have to go one back because we should stop on modifier (e.g 1m) iBeginIndex--; try { iValue = Integer.parseInt(strValue.substring(iNumberIndex, iBeginIndex)); } catch (NumberFormatException nmeExc) { // Incorrect String throw new Exception("Date function is in incorrect format: " + strValue + " at " + strValue.substring(iNumberIndex)); } // This has to be modifier: y - year, M - month, w - week, // d - day, h - hour, m - minute, s - second cChar = strValue.charAt(iBeginIndex); switch (cChar) { case (YEAR_CODE): { if (iDateType == DATE_TYPE_TIME) { throw new Exception( "Date function is in incorrect format: " + "used YEAR modifier for TIME type"); } workCal.add(Calendar.YEAR, iSign * iValue); break; } case (MONTH_CODE): { if (iDateType == DATE_TYPE_TIME) { throw new Exception( "Date function is in incorrect format: " + "used MONTH modifier for TIME type"); } workCal.add(Calendar.MONTH, iSign * iValue); break; } case (WEEK_CODE): { if (iDateType == DATE_TYPE_TIME) { throw new Exception( "Date function is in incorrect format: " + "used WEEK modifier for TIME type"); } workCal.add(Calendar.WEEK_OF_YEAR, iSign * iValue); break; } case (DAY_CODE): { if (iDateType == DATE_TYPE_TIME) { throw new Exception( "Date function is in incorrect format: " + "used DAY modifier for TIME type"); } workCal.add(Calendar.DATE, iSign * iValue); break; } case (HOUR_CODE): { if (iDateType == DATE_TYPE_DATE) { throw new Exception( "Date function is in incorrect format: " + "used HOUR modifier for DATE type"); } workCal.add(Calendar.HOUR, iSign * iValue); break; } case (MINUTE_CODE): { if (iDateType == DATE_TYPE_DATE) { throw new Exception("Date function is in incorrect format: " + "used MINUTE modifier for DATE type"); } workCal.add(Calendar.MINUTE, iSign * iValue); break; } case (SECOND_CODE): { if (iDateType == DATE_TYPE_DATE) { throw new Exception("Date function is in incorrect format: " + "used SECOND modifier for DATE type"); } workCal.add(Calendar.SECOND, iSign * iValue); break; } default: { // Incorrect String throw new Exception("Date function is in incorrect format: " + strValue + " at " + strValue.substring(iBeginIndex)); } } iBeginIndex++; } tsReturn = new Timestamp(workCal.getTimeInMillis()); } else { try { if (stored) { switch (iDateType) { case (DATE_TYPE_DATE): { tsReturn = new Timestamp(DATE_STORE_FORMAT.parse(strValue).getTime()); break; } case (DATE_TYPE_TIME): { tsReturn = new Timestamp(TIME_STORE_FORMAT.parse(strValue).getTime()); break; } case (DATE_TYPE_DATETIME): { tsReturn = new Timestamp(DATETIME_STORE_FORMAT.parse(strValue).getTime()); break; } default: { assert false : "Unknown date type " + iDateType; } } } else { switch (iDateType) { case (DATE_TYPE_DATE): { tsReturn = new Timestamp(DATE_FORMAT.parse(strValue).getTime()); break; } case (DATE_TYPE_TIME): { tsReturn = new Timestamp(TIME_FORMAT.parse(strValue).getTime()); break; } case (DATE_TYPE_DATETIME): { tsReturn = new Timestamp(DATETIME_FORMAT.parse(strValue).getTime()); break; } default: { assert false : "Unknown date type " + iDateType; } } } } catch (ParseException peExc) { throw new Exception("Date is in incorrect format. Problems with parsing.", peExc); } } } return tsReturn; }
From source file:Dates.java
/** * merge the date part and time part of two specified dates into a date. * //from ww w. j av a 2 s. co m * @param datePart * The date part date. * @param timePart * The time part date. * @param tz * The time zone. */ public static final Date merge(Date datePart, Date timePart, TimeZone tz) { if (tz == null) tz = TimeZones.getCurrent(); final Calendar dateCal = Calendar.getInstance(tz); dateCal.setTimeInMillis(datePart.getTime());// don't call cal.setTime(Date) // which will reset the // TimeZone. final Calendar timeCal = Calendar.getInstance(tz); timeCal.setTimeInMillis(timePart.getTime());// don't call cal.setTime(Date) // which will reset the // TimeZone. final int hour = timeCal.get(Calendar.HOUR); final int minute = timeCal.get(Calendar.MINUTE); final int second = timeCal.get(Calendar.SECOND); final int msillisecond = timeCal.get(Calendar.MILLISECOND); dateCal.set(Calendar.HOUR, hour); dateCal.set(Calendar.MINUTE, minute); dateCal.set(Calendar.SECOND, second); dateCal.set(Calendar.MILLISECOND, msillisecond); return dateCal.getTime(); }
From source file:com.planit.smsrenta.controladores.VehiculoBean.java
public List<SmsVehiculo> filtrarVehiculosDisponibles(SmsReservacion reserva, SmsCategoria cat, SmsMercado mercado, int categoriaServicio) { vehiculosListView = new ArrayList<>(); String categoriaVeh = cat.getCategoriaNombre(); String ciudadVeh = reserva.getSmsCiudadByIdCiudadInicio().getCiudadNombre(); String mercadoSeleccionado = mercado.getMercadoNombre(); Calendar calInicio = Calendar.getInstance(); calInicio.setTime(reserva.getReservacionHoraInicio()); calInicio.add(Calendar.HOUR, -1); calInicio.add(Calendar.MINUTE, -59); Calendar calLlegada = Calendar.getInstance(); calLlegada.setTime(reserva.getReservacionHoraLlegada()); calLlegada.add(Calendar.HOUR, 2); Date hespacioInicio = calInicio.getTime(); Date hespacioLlegada = calLlegada.getTime(); SimpleDateFormat formatDate;// w w w. j a va2s.c om SimpleDateFormat formatTime; formatDate = new SimpleDateFormat("yyyy-MM-dd"); formatTime = new SimpleDateFormat("HH:mm:ss"); String FechaInicio = formatDate.format(reserva.getReservacionFechaInicio()); String FechaLlegada = formatDate.format(reserva.getReservacionFechaLlegada()); String HoraInicio = formatTime.format(reserva.getReservacionHoraInicio()); String HoraLlegada = formatTime.format(reserva.getReservacionHoraLlegada()); String espacioinicio = formatTime.format(hespacioInicio); String espacioLlegada = formatTime.format(hespacioLlegada); vehiculosListView = vehDao.filtrarVehiculosDisponibles(FechaInicio, FechaLlegada, HoraInicio, HoraLlegada, ciudadVeh, categoriaVeh, espacioinicio, espacioLlegada, mercadoSeleccionado, categoriaServicio); return vehiculosListView; }
From source file:edu.byu.softwareDist.manager.impl.PurchaseManagerImpl.java
private PendingPurchase createPendingPurchase(final Integer purchaseId, final String ownerId) { PendingPurchase pendingPurchase = new PendingPurchase(); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR, 1); pendingPurchase.setExpireTime(calendar.getTime()); pendingPurchase.setPurchaseId(purchaseId); pendingPurchase.setStatus("PENDING"); pendingPurchase.setOwnerId(ownerId); return pendingPurchaseDao.save(pendingPurchase); }
From source file:ac.elements.parser.ExtendedFunctions.java
/** * Formats a number given as the number of milliseconds String or Long and * converts it to a format "H'h' m'm' s's'". Periods longer then a day do * not work in this method. If conversion doesn't work it returns the Object * casted as a string. (SimpleDateFormat syntax). * /*from ww w . j ava2s.c om*/ * @returns null if myObject is null, otherwise a formatted time period as a * string. * @see java.text.SimpleDateFormat */ public static String timePeriod(Object myObject) { long timePeriodInMilliseceonds = 0; if (myObject == null) return null; try { if (myObject instanceof String) { timePeriodInMilliseceonds = Long.parseLong(myObject.toString()); } else if (myObject instanceof Number) { timePeriodInMilliseceonds = ((Number) myObject).longValue(); } else { return "Not supported: ".concat(myObject.getClass().getName()); } String format = "D' days' H'h' mm'm' ss's'"; if (timePeriodInMilliseceonds < 60 * 1000l) format = "ss's'"; else if (timePeriodInMilliseceonds < 3600 * 1000l) format = "mm'm' ss's'"; else if (timePeriodInMilliseceonds < 3600 * 24 * 1000l) format = "H'h' mm'm' ss's'"; else if (timePeriodInMilliseceonds < 3600 * 48 * 1000l) { format = "D' day' H'h' mm'm' ss's'"; } // Get Greenwich time zone. TimeZone theTz = TimeZone.getTimeZone("GMT"); SimpleDateFormat mySimpleDateFormat = new SimpleDateFormat(format); mySimpleDateFormat.setTimeZone(theTz); // create a date in the locale's calendar, // set its timezone and hour. Calendar day = Calendar.getInstance(); day.setTimeZone(theTz); day.setTime(new Date(timePeriodInMilliseceonds)); day.roll(Calendar.DAY_OF_MONTH, false); day.set(Calendar.HOUR, day.get(Calendar.HOUR)); return mySimpleDateFormat.format(day.getTime()); } catch (NullPointerException npe) { // npe.printStackTrace(); return null; } catch (NumberFormatException nfe) { // nfe.printStackTrace(); return null; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:fr.inria.ucn.Helpers.java
/** * // w ww .j av a2 s . c o m * @param c * @return -1 if not at night-time (or feature disabled), else milliseconds until morning. */ public static long getNightEnd(Context c) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c); if (!prefs.getBoolean(Constants.PREF_STOP_NIGHT, false)) return -1; int nstart = prefs.getInt(Constants.PREF_NIGHT_START, 23 * 3600); int nstop = prefs.getInt(Constants.PREF_NIGHT_STOP, 6 * 3600); Calendar nightstart = Calendar.getInstance(); nightstart.roll(Calendar.HOUR_OF_DAY, -1 * nightstart.get(Calendar.HOUR_OF_DAY)); nightstart.roll(Calendar.MINUTE, -1 * nightstart.get(Calendar.MINUTE)); nightstart.roll(Calendar.SECOND, -1 * nightstart.get(Calendar.SECOND)); nightstart.roll(Calendar.MILLISECOND, -1 * nightstart.get(Calendar.MILLISECOND)); nightstart.add(Calendar.SECOND, nstart); Calendar nightstop = Calendar.getInstance(); nightstop.roll(Calendar.HOUR_OF_DAY, -1 * nightstop.get(Calendar.HOUR_OF_DAY)); nightstop.roll(Calendar.MINUTE, -1 * nightstop.get(Calendar.MINUTE)); nightstop.roll(Calendar.SECOND, -1 * nightstop.get(Calendar.SECOND)); nightstop.roll(Calendar.MILLISECOND, -1 * nightstop.get(Calendar.MILLISECOND)); nightstop.add(Calendar.SECOND, nstop); if (nightstop.before(nightstart)) nightstop.add(Calendar.HOUR, 24); Log.d(Constants.LOGTAG, "nightstart " + nstart + " -> " + nightstart.toString()); Log.d(Constants.LOGTAG, "nightstop " + nstop + " -> " + nightstop.toString()); Calendar now = Calendar.getInstance(); if (now.after(nightstart) && now.before(nightstop)) { return nightstop.getTimeInMillis(); } else { return -1; } }
From source file:ezbake.data.elastic.IT_EzElasticIntegrationTest.java
@Test public void testRangeDateFacets() throws Exception { // Prepare: Setup Thrift Client and add some docs final SimpleDateFormat dtg = new SimpleDateFormat("ddHHmm'Z' MM yy"); client = pool.getClient(SERVICE_NAME, EzElastic.Client.class); client.setTypeMapping(TEST_TYPE, getMappingForTest(), fakeSecurity); client.bulkPut(Arrays.asList(jeffersonMemorialDoc, whiteHouseDoc, columbiaDoc, lincolnMemorialDoc), fakeSecurity);// www .java2 s . c o m Calendar calendar = new GregorianCalendar(); calendar.add(Calendar.DAY_OF_YEAR, -1); long last24Time = DateUtils.round(calendar, Calendar.HOUR).getTimeInMillis(); calendar.add(Calendar.DAY_OF_YEAR, -1); long last48Time = DateUtils.round(calendar, Calendar.HOUR).getTimeInMillis(); calendar.add(Calendar.DAY_OF_YEAR, -1); long last72Time = DateUtils.round(calendar, Calendar.HOUR).getTimeInMillis(); List<Facet> rangeDateFacets = Collections .singletonList(EzElasticTestUtils.generateDateBucketFacet(last24Time, last48Time, last72Time)); // Action: Create and execute a match all query with date bucket facets final Query query = new Query(QueryBuilders.matchAllQuery().toString()); query.setType(TEST_TYPE).setFacets(rangeDateFacets).setPage(new Page(0, (short) 10)); final SearchResult results = client.query(query, fakeSecurity); // Assert: All records should be a match and the facet buckets should be organized as expected assertEquals(4, results.getTotalHits()); assertFalse(results.getFacets().isEmpty()); assertTrue(results.getFacets().containsKey("Report Date")); final FacetResult facetResult = results.getFacets().get("Report Date"); for (final RangeFacetEntry entry : facetResult.getRangeFacetResult().getEntries()) { if (dtg.parse(entry.getRangeFrom()).getTime() >= last24Time || dtg.parse(entry.getRangeFrom()).getTime() >= last48Time || dtg.parse(entry.getRangeFrom()).getTime() >= last72Time) { assertEquals(3, entry.getCount()); } else { assertEquals(4, entry.getCount()); } } pool.returnToPool(client); }
From source file:es.udc.fic.test.model.CerrarMangaTest.java
public void addData() { //Creamos una sola regata con la instancia de todos los objetos en memoria regata = new Regata(); regata.setNombre("Mock Regata"); regata.setDescripcion("Mock Desc"); regataDao.save(regata);/*from www .j a va2 s . c o m*/ Tipo tipoCruceros = new Tipo("Cruceros", "Desc Cruceros", false); tipoDao.save(tipoCruceros); Tipo tipoLanchas = new Tipo("Lanchas", "Desc Lanchas", false); tipoDao.save(tipoLanchas); b1 = new Barco(204566, "Juan Sebastian El Cano", tipoCruceros, (float) 1.5, "X6"); inscripcionService.inscribir(regata, b1, "Iago Surez"); b2 = new Barco(199012, "El Holandes Errante", tipoCruceros, (float) 1.8, "X2"); inscripcionService.inscribir(regata, b2, "Samu Paredes"); b3 = new Barco(201402, "La Perla Negra", tipoCruceros, (float) 1.0, "X8"); inscripcionService.inscribir(regata, b3, "Adrian Pallas"); b4 = new Barco(202102, "La Pinta", tipoCruceros, (float) 2.0, "X7"); inscripcionService.inscribir(regata, b4, "Pedro Cabalar"); b5 = new Barco(182345, "Venus", tipoCruceros, (float) 1.5, "X7"); //Ponemos otro tipo para ver como funciona la clasificacion inscripcionService.inscribir(regata, b5, "Jesus Lopez"); b6 = new Barco(206745, "Apolo", tipoLanchas, null, "Motora"); inscripcionService.inscribir(regata, b6, "Diego Bascoy"); Calendar dia1 = Calendar.getInstance(); dia1.add(Calendar.DAY_OF_YEAR, -18); Calendar dia2 = Calendar.getInstance(); dia2.add(Calendar.DAY_OF_YEAR, -18); dia2.add(Calendar.HOUR, 2); Calendar dia3 = Calendar.getInstance(); dia3.add(Calendar.DAY_OF_YEAR, -17); // COMPROBAMOS LAS DESCALIFICACIONES QUE NO ACARREAN EL MAX DE PUNT. manga1 = new Manga(dia1, regata, null, 100); List<Posicion> posManga1 = new ArrayList<Posicion>(); //NAN -> 0 penal //ZFP -> 20% penal //SCP RDG DPI -> Penal en tiempo //Cruceros // ZFP (3000 + 1.5* 100 )* 1.20 = 3780s -> Tercero posManga1.add(new Posicion((long) 3000, Posicion.Penalizacion.ZFP, manga1, b1, null)); //SCP (3300 + 1.5 * 100) + 150s = 3600s -> Segundo posManga1.add(new Posicion((long) 3300, Posicion.Penalizacion.SCP, manga1, b2, (long) 150)); //NAN (3400 + 1.0 * 100) = 3500s -> Primero posManga1.add(new Posicion((long) 3400, Posicion.Penalizacion.NAN, manga1, b3, (long) 0)); //RDG (3750 + 2.0 *100 ) = 3950s -> Cuarto posManga1.add(new Posicion((long) 3750, Posicion.Penalizacion.RDG, manga1, b4, (long) 0)); //DPI (3800+60) +(1.5 *100) = 4010s -> Quinto posManga1.add(new Posicion((long) 3800, Posicion.Penalizacion.DPI, manga1, b5, (long) 60)); //Lanchas //Primero -> Puntos 1 posManga1.add(new Posicion((long) 3300, Posicion.Penalizacion.ZFP, manga1, b6, (long) 0)); manga1.setPosiciones(posManga1); mangaService.cerrarYGuardarManga(manga1); regata.addManga(manga1); //Comprobamos que los puntos son correctos //Guardamos las posiciones por tipos posPorBarco = new HashMap<Barco, Posicion>(); for (Posicion p : manga1.getPosiciones()) { //Aadimos la posicionActual posPorBarco.put(p.getBarco(), p); } // COMPROBAMOS LAS DESCALIFICACIONES QUE ACARREAN EL MAX DE PUNT. manga2 = new Manga(dia2, regata, null, 100); List<Posicion> posManga2 = new ArrayList<Posicion>(); //DNC DNS -> No Salio // DNF RET DSQ -> No termino / Retirado / Descalificado // DNE DGM -> Descalificaciones Graves // BFD -> Bandera negra //Velas Ligeras // ZFP 3600s -> Primero (unico el llegar) posManga2.add(new Posicion((long) 3000, Posicion.Penalizacion.ZFP, manga1, b1, (long) 0)); //DNF No termino -> Ultimo -> 6 Puntos posManga2.add(new Posicion((long) 3300, Posicion.Penalizacion.DNF, manga1, b2, null)); //DNE Descalificado -> Ultimo -> 6 Puntos posManga2.add(new Posicion((long) 3400, Posicion.Penalizacion.DNE, manga1, b3, null)); //DNE Descalificado -> Ultimo -> 6 Puntos posManga2.add(new Posicion((long) 3750, Posicion.Penalizacion.DNE, manga1, b4, null)); //DGM Descalificado -> Ultimo -> 6 Puntos posManga2.add(new Posicion((long) 3800, Posicion.Penalizacion.DGM, manga1, b5, null)); //Lanchas //RET Retirado -> Puntos 2 posManga2.add(new Posicion((long) 3300, Posicion.Penalizacion.RET, manga1, b6, null)); manga2.setPosiciones(posManga2); mangaService.cerrarYGuardarManga(manga2); regata.addManga(manga2); }