List of usage examples for java.sql Timestamp getDate
@Deprecated public int getDate()
From source file:com.dc.gameserver.extComponents.Kit.DateUtil.java
/** * ???//from w w w. ja va 2 s .c o m * 8? 12? 19? 21? * @param lastTime * @param nowTime * @return */ @SuppressWarnings("deprecation") public static boolean getFreeActPoint(Timestamp lastTime, Timestamp nowTime) { int lastTimeCount = lastTime.getHours() * 60 + lastTime.getMinutes(); int nowTimeCount = nowTime.getHours() * 60 + nowTime.getMinutes(); int count1 = 8 * 60 + 30; int count2 = 12 * 60 + 30; int count3 = 19 * 60 + 30; //? if (lastTime.getDate() == nowTime.getDate()) { if (lastTimeCount >= count3) { return false; } else if (lastTimeCount < count1) return nowTimeCount >= count1; else if (lastTimeCount >= count1 && lastTimeCount < count2) { return nowTimeCount >= count2; } else if (lastTimeCount >= count2 && lastTimeCount < count3) { return nowTimeCount >= count3; } } else { if (lastTimeCount >= count3) { return nowTimeCount >= count1; } } return true; }
From source file:com.google.visualization.datasource.util.SqlDataSourceHelper.java
/** * Creates a table cell from the value in the current row of the given result * set and the given column index. The type of the value is determined by the * given value type.//from w ww. jav a2 s. com * * @param rs The result set holding the data from the sql table. The result * points to the current row. * @param valueType The value type of the column that the cell belongs to. * @param column The column index. Indexes are 0-based. * * @return The table cell. * * @throws SQLException Thrown when the connection to the database failed. */ private static TableCell buildTableCell(ResultSet rs, ValueType valueType, int column) throws SQLException { Value value = null; // SQL indexes are 1- based. column = column + 1; switch (valueType) { case BOOLEAN: value = BooleanValue.getInstance(rs.getBoolean(column)); break; case NUMBER: value = new NumberValue(rs.getDouble(column)); break; case DATE: Date date = rs.getDate(column); // If date is null it is handled later. if (date != null) { GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT")); // Set the year, month and date in the gregorian calendar. // Use the 'set' method with those parameters, and not the 'setTime' // method with the date parameter, since the Date object contains the // current time zone and it's impossible to change it to 'GMT'. gc.set(date.getYear() + 1900, date.getMonth(), date.getDate()); value = new DateValue(gc); } break; case DATETIME: Timestamp timestamp = rs.getTimestamp(column); // If timestamp is null it is handled later. if (timestamp != null) { GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT")); // Set the year, month, date, hours, minutes and seconds in the // gregorian calendar. Use the 'set' method with those parameters, // and not the 'setTime' method with the timestamp parameter, since // the Timestamp object contains the current time zone and it's // impossible to change it to 'GMT'. gc.set(timestamp.getYear() + 1900, timestamp.getMonth(), timestamp.getDate(), timestamp.getHours(), timestamp.getMinutes(), timestamp.getSeconds()); // Set the milliseconds explicitly, as they are not saved in the // underlying date. gc.set(Calendar.MILLISECOND, timestamp.getNanos() / 1000000); value = new DateTimeValue(gc); } break; case TIMEOFDAY: Time time = rs.getTime(column); // If time is null it is handled later. if (time != null) { GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT")); // Set the hours, minutes and seconds of the time in the gregorian // calendar. Set the year, month and date to be January 1 1970 like // in the Time object. // Use the 'set' method with those parameters, // and not the 'setTime' method with the time parameter, since // the Time object contains the current time zone and it's // impossible to change it to 'GMT'. gc.set(1970, Calendar.JANUARY, 1, time.getHours(), time.getMinutes(), time.getSeconds()); // Set the milliseconds explicitly, otherwise the milliseconds from // the time the gc was initialized are used. gc.set(GregorianCalendar.MILLISECOND, 0); value = new TimeOfDayValue(gc); } break; default: String colValue = rs.getString(column); if (colValue == null) { value = TextValue.getNullValue(); } else { value = new TextValue(rs.getString(column)); } break; } // Handle null values. if (rs.wasNull()) { return new TableCell(Value.getNullValueFromValueType(valueType)); } else { return new TableCell(value); } }
From source file:business.security.control.OwmClient.java
@Schedule(second = "0", minute = "0", hour = "*", persistent = false) public void checkWeather() { System.out.println("Inizio check"); List<Place> listPlaceInDb; List<Forecast> listForecastInDb = new ArrayList<Forecast>(); listPlaceInDb = placeManager.getAllPlaces(); List<Forecast> tmp = new ArrayList<Forecast>(); for (Place p : listPlaceInDb) { tmp = forecastManager.getForecastInPlace(p); for (Forecast f : tmp) { listForecastInDb.add(f);//w ww . jav a2s .c om } } //Adesso ho nella mia lista tutti i forecast del mio db //Devo pulire quelli con la data vecchia Timestamp now = new Timestamp(new java.util.Date().getTime()); for (Forecast f : listForecastInDb) { if ((f.getDate().getYear() < now.getYear()) || (f.getDate().getMonth() < now.getMonth()) || (f.getDate().getDate() < now.getDate())) { System.out .println("Sto rimuovendo il forecast: " + f.getPlace().getCity() + " " + f.getDate() + now); entityManager.remove(entityManager.find(Forecast.class, f.getId())); } } listForecastInDb = new ArrayList<Forecast>(); for (Place p : listPlaceInDb) { for (Forecast f : forecastManager.getForecastInPlace(p)) { listForecastInDb.add(f); } } //Qui nel mio database dovrei avere solo forecast aggiornati for (Place p : listPlaceInDb) { try { WeatherForecastResponse risposta; risposta = this.tenForecastWeatherAtCity(p.getCity()); List<ForecastWeatherData> list = risposta.getForecasts(); for (ForecastWeatherData fwd : list) { if (!alreadyIn(fwd, p.getCity())) { Timestamp t = new Timestamp(fwd.getCalcDateTime()); System.out.println("Sto aggiungendo/aggiornando il forecast : " + p.getCity() + " " + t); Forecast f = new Forecast(); //Recupero nel database la main condition associata MainCondition mc = new MainCondition(); mc.setCondition(fwd.getWeatherConditions().get(0).getMain()); entityManager.merge(mc); //Ho preparato tutti i parametri necessari f.setPlace(p); f.setMainCondition(mc); f.setDate(new Timestamp(fwd.getCalcDateTime())); entityManager.persist(f); } } } catch (JSONException ex) { Logger.getLogger(EventBean.class.getName()).log(Level.WARNING, null, "Too much requests to the ForecastServer"); } catch (IOException ex) { Logger.getLogger(EventBean.class.getName()).log(Level.SEVERE, null, ex); } } System.out.println("Check Weather Completed!"); }
From source file:business.security.control.OwmClient.java
private boolean alreadyIn(ForecastWeatherData fwd, String city) { ArrayList<Forecast> listForecastInDb = new ArrayList<Forecast>(); Iterable<Place> listPlaceInDb; Timestamp date = new Timestamp(fwd.getCalcDateTime()); listPlaceInDb = placeManager.getAllPlaces(); for (Place p : listPlaceInDb) { for (Forecast f : forecastManager.getForecastInPlace(p)) { listForecastInDb.add(f);// w w w . j a v a2 s. c om } } for (Forecast f : listForecastInDb) { if (f.getPlace().getCity().equals(city) && f.getDate().getYear() == date.getYear() && f.getDate().getMonth() == date.getMonth() && f.getDate().getDate() == date.getDate()) { if (!(f.getMainCondition().getCondition().equals(fwd.getWeatherConditions().get(0).getMain()))) { entityManager.remove(entityManager.find(Forecast.class, f.getId())); return false; } return true; } } return false; }
From source file:org.eevolution.form.CRP.java
/** * Create Category Dataset based on date start and resource * @param start// w w w. j av a2 s . co m * @param resource * @return CategoryDataset */ protected CategoryDataset createDataset(Timestamp start, MResource resource) { GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND); gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); Timestamp date = start; String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); String nameload = Msg.translate(Env.getCtx(), "Load"); String namesummary = Msg.translate(Env.getCtx(), "Summary"); MResourceType t = MResourceType.get(Env.getCtx(), resource.getS_ResourceType_ID()); int days = 1; long hours = t.getTimeSlotHours(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Long Hours = new Long(hours); int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ", resource.getS_Resource_ID()); MUOM uom = MUOM.get(Env.getCtx(), C_UOM_ID); if (!uom.isHour()) { return dataset; } long summary = 0; while (days < 32) { String day = new String(new Integer(date.getDate()).toString()); long HoursLoad = getLoad(resource, date).longValue(); Long Hours = new Long(hours); switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: days++; if (t.isOnSunday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.MONDAY: days++; if (t.isOnMonday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.TUESDAY: days++; if (t.isOnTuesday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.WEDNESDAY: days++; if (t.isOnWednesday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.THURSDAY: days++; if (t.isOnThursday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.FRIDAY: days++; if (t.isOnFriday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.SATURDAY: days++; if (t.isOnSaturday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } } } return dataset; }
From source file:org.eevolution.form.VSCRP.java
public CategoryDataset createDataset(Timestamp start, MResource r) { //System.out.println("Create new data set"); GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND);//from www . ja v a 2 s . c om gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); Timestamp date = start; String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); System.out.println("\n Namecapacity :" + namecapacity); String nameload = Msg.translate(Env.getCtx(), "Load"); System.out.println("\n Nameload :" + nameload); String namesummary = Msg.translate(Env.getCtx(), "Summary"); System.out.println("\n Namesummary :" + namesummary); MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); System.out.println("\n Resourcetype " + t); int days = 1; long hours = 0; if (t.isTimeSlot()) { hours = MMPCMRP.getHoursAvailable(t.getTimeSlotStart(), t.getTimeSlotEnd()); } else { //fjviejo e-evolution MachineQty if (r.getDailyCapacity().multiply(r.getMachineQty()).compareTo(Env.ZERO) != 0) hours = r.getDailyCapacity().multiply(r.getMachineQty()).longValue(); else //fjviejo e-evolution end hours = 24; } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Long Hours = new Long(hours); int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ", r.getS_Resource_ID()); MUOM uom = new MUOM(Env.getCtx(), C_UOM_ID, null); System.out.println("\n uom1 " + uom + "\n"); //System.out.println("um.isHour()"+ uom.isHour() ); if (!uom.isHour()) { System.out.println("\n uom2 " + uom + "\n"); return dataset; } System.out.println("\n Dataset " + dataset + "\n"); int summary = 0; int secondsAcum = 0; long hoursAcum = 0; while (days < 29) { //System.out.println("Day Number" + days); String day = new String(new Integer(date.getDate()).toString()); System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID()); System.out.println("Date:" + date); int seconds = getLoad(r.getS_Resource_ID(), date, date); Long Hours = new Long(hours); System.out.println("Summary " + summary); System.out.println("Capacity " + hours); System.out.println("Load " + seconds); /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** secondsAcum y hoursAcum llevan los acumulados para la semana ** los reinicio en cada nueva semana. ** ** VIT4B - 07/12/2006 */ if (days == 1 || days == 8 || days == 15 || days == 22) { secondsAcum = 0; hoursAcum = 0; } secondsAcum += seconds; hoursAcum += hours; switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: if (t.isOnSunday()) { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary + Hours.intValue() - (seconds / 3600); //+ (Hours.intValue() - ((seconds / 3600))); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.MONDAY: if (t.isOnMonday()) { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.TUESDAY: if (t.isOnTuesday()) { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.WEDNESDAY: if (t.isOnWednesday()) { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.THURSDAY: if (t.isOnThursday()) { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.FRIDAY: if (t.isOnFriday()) { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.SATURDAY: if (t.isOnSaturday()) { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { /* ** Realizo la verificacin sobre que da me encuentro ** para graficar cada 7 dias el estado de la semana. ** ** VIT4B - 07/12/2006 */ if (days == 7 || days == 14 || days == 21 || days == 28) { dataset.addValue(hoursAcum, namecapacity, day); dataset.addValue(secondsAcum / 3600, nameload, day); dataset.addValue(summary, namesummary, day); } summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } } days++; } return dataset; }
From source file:org.eevolution.form.VCRP.java
public CategoryDataset createDataset(Timestamp start, MResource r) { //System.out.println("Create new data set"); GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND);/*from w w w. j a v a2 s.c om*/ gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); Timestamp date = start; String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); System.out.println("\n Namecapacity :" + namecapacity); String nameload = Msg.translate(Env.getCtx(), "Load"); System.out.println("\n Nameload :" + nameload); String namesummary = Msg.translate(Env.getCtx(), "Summary"); System.out.println("\n Namesummary :" + namesummary); MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); System.out.println("\n Resourcetype " + t); int days = 1; long hours = 0; if (t.isTimeSlot()) { hours = MMPCMRP.getHoursAvailable(t.getTimeSlotStart(), t.getTimeSlotEnd()); } else { //fjviejo e-evolution MachineQty if (r.getDailyCapacity().multiply(r.getMachineQty()).compareTo(Env.ZERO) != 0) hours = r.getDailyCapacity().multiply(r.getMachineQty()).longValue(); else //fjviejo e-evolution end hours = 24; } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Long Hours = new Long(hours); int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ", r.getS_Resource_ID()); MUOM uom = new MUOM(Env.getCtx(), C_UOM_ID, null); System.out.println("\n uom1 " + uom + "\n"); //System.out.println("um.isHour()"+ uom.isHour() ); if (!uom.isHour()) { System.out.println("\n uom2 " + uom + "\n"); return dataset; } System.out.println("\n Dataset " + dataset + "\n"); int summary = 0; //int cont = 1; DateFormat formatter = DateFormat.getDateInstance(); /* * Vit4B Modificado para que tome 28 dias y * * */ while (days < 29) { /* * VIT4B MODIFICACION PARA ACUMULADO DE DIAS * * * //System.out.println("Day Number" + days); String strday = formatter.format(date); //String day = new String(new Integer (date.getDate()).toString()); String day = new String(formatter.format(date)); //day = day.substring(0,5); int index = day.indexOf("/"); String str = day.substring(0,index); System.out.println("str: " + str + " index de / " + index); String str2 = day.substring(index+1,day.length()); System.out.println("str2 resto: " + str2); index = str2.indexOf("/"); System.out.println(index); String str3 = str2.substring(0,index); System.out.println("str3: " + str3 + " index de / " + index); String str4 = str2.substring(index+1,str2.length()); System.out.println(str4); System.out.println("dia: " + str); System.out.println("mes: " + str3); System.out.println("ao: " + str4); //day = str + str3; day = new String(str + str3); //day = day.substring(0,day.lastIndexOf("/")); //day =day.substring(0,3); //cont++; System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID()); System.out.println("Date: " + date + " day: " + day); int seconds = getLoad(r.getS_Resource_ID(),date ,date); Long Hours = new Long(hours); System.out.println("Summary "+ summary); System.out.println("Capacity "+ hours); System.out.println("Load "+ seconds); /* * * VIT4B MODIFICACION PARA ACUMULADO DE DIAS * * */ /* * ORIGINAL COMPIERE */ String day = new String(new Integer(date.getDate()).toString()); System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID()); System.out.println("Date:" + date); /* * VIT4B - Modificacin para calcular como se calcula el reporte CCRP * en funcion de la carga parcial * * */ int seconds = getLoad(r.getS_Resource_ID(), date, date); //BigDecimal value = calculateLoad(date, r, null); //int seconds = value.intValue(); Long Hours = new Long(hours); System.out.println("Summary " + summary); System.out.println("Load " + seconds); /* * FIN ORIGINAL COMPIERE * */ switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: days++; if (t.isOnSunday()) { //System.out.println("si Sunday"); //Msg.translate(Env.getCtx(), "OnSunday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); //+ (Hours.intValue() - ((seconds / 3600))); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no Sunday"); //String day = Msg.translate(Env.getCtx(), "OnSunday") ; dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.MONDAY: days++; if (t.isOnMonday()) { //System.out.println("si Monday"); //String day = Msg.translate(Env.getCtx(), "OnMonday") ; dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no Monday"); //String day = Msg.translate(Env.getCtx(), "OnMonday") ; dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.TUESDAY: days++; if (t.isOnTuesday()) { //System.out.println("si TuesDay"); //String day = Msg.translate(Env.getCtx(), "OnTuesday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no TuesDay"); //String day = Msg.translate(Env.getCtx(), "OnTuesday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.WEDNESDAY: days++; if (t.isOnWednesday()) { //String day = Msg.translate(Env.getCtx(), "OnWednesday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnWednesday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.THURSDAY: days++; if (t.isOnThursday()) { //String day = Msg.translate(Env.getCtx(), "OnThursday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnThursday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.FRIDAY: days++; if (t.isOnFriday()) { //String day = Msg.translate(Env.getCtx(), "OnFriday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnFriday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.SATURDAY: days++; if (t.isOnSaturday()) { //String day = Msg.translate(Env.getCtx(), "OnSaturday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnSaturday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } } } return dataset; }
From source file:org.apache.openjpa.persistence.kernel.TestProxies2.java
public void testTimestamp() { OpenJPAEntityManager pm = getPM(true, true); startTx(pm);// w w w . j a v a 2 s . c om ProxiesPC pc = pm.find(ProxiesPC.class, _oid); java.sql.Timestamp tstamp = pc.getTimestamp(); assertNotNull(tstamp); // dates can lose precision, but make sure same day assertEquals(_timestamp.getYear(), tstamp.getYear()); assertEquals(_timestamp.getMonth(), tstamp.getMonth()); assertEquals(_timestamp.getDate(), tstamp.getDate()); // make sure proxied assertTrue(!pm.isDirty(pc)); tstamp.setNanos(100); assertTrue(pm.isDirty(pc)); endTx(pm); assertEquals(tstamp, pc.getTimestamp()); endEm(pm); }