public double getNormalForMonth(int month, StatIndex stat) {
    GregorianCalendar calendar = new GregorianCalendar(2001, month, 1);
    int lastDayOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    calendar.set(Calendar.DAY_OF_MONTH, lastDayOfMonth);

    return getNormalMonthToDate(calendar, stat);
  }
  @RequestMapping(
      value = "/form",
      method = RequestMethod.POST,
      consumes = "application/x-www-form-urlencoded")
  @ResponseBody
  public Event addEventForm(
      @RequestParam String keyword,
      @RequestParam String theDay,
      @RequestParam String startDate,
      @RequestParam String duration,
      @RequestParam String initialEvent) {
    if (diaryHelper.md5(keyword).equals(password)) {
      Event event = new Event();
      event.setDescription(initialEvent);
      event.setDuration(diaryHelper.getDuration(duration));
      GregorianCalendar startDateCal = diaryHelper.getStartDateCal(startDate);
      event.setStartTime(startDateCal.getTime());

      event.setId(
          diaryService.addEvent(DateUtil.resetHMS(diaryHelper.getDayCal(theDay).getTime()), event));

      return event;
    }
    return new Event();
  }
  private static void parseFinancialDataFromXml(
      List<FinancialDataClass> list, int xmlResource, Resources resources) {
    BufferedReader reader =
        new BufferedReader(new InputStreamReader(resources.openRawResource(xmlResource)));
    try {
      String line = reader.readLine();
      while (line != null) {
        String[] tokens = line.split("\t");
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(dateFormat.parse(tokens[0], new ParsePosition(0)));
        FinancialDataClass data =
            new FinancialDataClass(
                calendar,
                Float.parseFloat(tokens[1]),
                Float.parseFloat(tokens[2]),
                Float.parseFloat(tokens[3]),
                Float.parseFloat(tokens[4]),
                Float.parseFloat(tokens[5]));
        list.add(data);
        line = reader.readLine();
      }

      reader.close();

    } catch (IOException ex) {
      list = null;
      throw new Error("Could not read financial data from xml.");
    }
  }
Beispiel #4
0
  /**
   * Draws a time sync line on the plot at the specified time. We take the approach of plotting the
   * time sync line like another data series in preference to using Quinn-Curtis' line drawing
   * function.
   *
   * @param time at which to draw the time sync line.
   */
  void drawTimeSyncLineAtTime(GregorianCalendar time) {
    assert time != null;

    // Peg timesync line to the plot area by setting the time
    // parameter to be on the plot max or plot min.
    if (time.before(plot.getCurrentTimeAxisMin())) {
      time = plot.getCurrentTimeAxisMin();
    } else if (time.after(plot.getCurrentTimeAxisMax())) {
      time = plot.getCurrentTimeAxisMax();
    }

    syncTime = time;

    if (timeSyncLinePlot == null) {
      AbstractAxis timeAxis = plot.getTimeAxis();
      if (timeAxis instanceof XYAxis) { // Only decorate time-like axes; TODO: move to AbstractAxis?
        timeSyncLinePlot = new XYMarkerLine((XYAxis) timeAxis, time.getTimeInMillis());
        timeSyncLinePlot.setForeground(PlotConstants.TIME_SYNC_LINE_COLOR);
        XYPlotContents contents = plot.getPlotView().getContents();
        contents.add(timeSyncLinePlot);
        contents.revalidate();
      }
    } else {
      timeSyncLinePlot.setValue(time.getTimeInMillis());
    }
  }
 private void monthChanged() {
   refreshCalendar();
   heading.setText(
       calendar.getDisplayName(GregorianCalendar.MONTH, GregorianCalendar.LONG, Locale.ENGLISH)
           + " "
           + calendar.get(GregorianCalendar.YEAR));
 }
  @Test
  public void testFindByDate() {

    Company company = new CompanyBuilder().build();

    Candidate candidate1 =
        new CandidateBuilder()
            .withName(new Name("Candidate1"))
            .withEmail("*****@*****.**")
            .withCompany(company)
            .build();
    Candidate candidate2 =
        new CandidateBuilder().withName(new Name("Candidate2")).withCompany(company).build();
    Candidate candidate3 =
        new CandidateBuilder().withName(new Name("Candidate3")).withCompany(company).build();

    companyDao.save(company);
    candidateDao.save(candidate1);
    candidateDao.save(candidate2);
    candidateDao.save(candidate3);

    GregorianCalendar start = new GregorianCalendar();
    start.add(Calendar.HOUR_OF_DAY, -24);
    GregorianCalendar end = new GregorianCalendar();

    List<Candidate> results = candidateDao.findByCompanyIDandDateRange(company.getId(), start, end);
    assertEquals(3, results.size());
  }
Beispiel #7
0
 public Employee(String n, String work, int salary, int year, int month, int day) {
   super(n);
   this.work = work;
   this.salary = salary;
   GregorianCalendar calendar = new GregorianCalendar(year, month - 1, day);
   hireday = calendar.getTime();
 }
  private ContentValues getContent() {
    ContentValues content = new ContentValues();
    EditText aux;

    Long id = getId();
    if (id != -1) {
      content.put("_id", id);
    }

    // date
    DatePicker dp = (DatePicker) findViewById(R.id.date);
    GregorianCalendar date = new GregorianCalendar(dp.getYear(), dp.getMonth(), dp.getDayOfMonth());
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    content.put("date", sdf.format(date.getTime()));

    // km
    aux = (EditText) findViewById(R.id.km);
    content.put("odometer", Float.parseFloat(aux.getText().toString()));

    // liters
    aux = (EditText) findViewById(R.id.liters);
    content.put("liters", Float.parseFloat(aux.getText().toString()));

    // type
    RadioGroup aux2 = (RadioGroup) findViewById(R.id.type);
    RadioButton aux3 = (RadioButton) findViewById(aux2.getCheckedRadioButtonId());
    content.put("fuel", aux3.getText().toString());

    return content;
  }
Beispiel #9
0
  public void execute() {
    // Initialize a Reminder or more than one Reminders.
    boolean booleanReminder = false;
    if (mStrReminder.compareTo(mStrReminder) == 0) booleanReminder = true;
    Reminder[] reminders = new Reminder[1];
    if (mStrMinute.compareTo("On day of event") == 0) {
      Date dateReminder = getDateTime(mStrStartTime);
      GregorianCalendar gregorianCalendarReminder = new GregorianCalendar();
      gregorianCalendarReminder.setTime(dateReminder);
      mStrMinute =
          Integer.toString(
              gregorianCalendarReminder.get(Calendar.HOUR_OF_DAY) * 60
                  + gregorianCalendarReminder.get(Calendar.MINUTE));
    }

    reminders[0] = new Reminder(mStrMinute, mStrMethod, booleanReminder);

    // Initialize a Recurrence.

    // Initialize a Where.
    Where where = new Where(mStrLocation);

    // Initialize a When.
    When when =
        new When(
            getStrDateWithTimeZone(mStrStartTime), getStrDateWithTimeZone(mStrEndTime), reminders);

    // Initialize an Event.
    Event event = new Event(mStrTitle, mStrContent, where, when);

    // Post to Calendar for adding a new event of default calendar.
    Event eventNew = null;
    try {
      eventNew = mCalendarServer.postEventEntry("", event);
    } catch (IOException e) {
      Bundle bundleSend = new Bundle();
      eventNew = new Event(false);
      bundleSend.putSerializable("Data", eventNew);
      bundleSend.putInt("ErrorCode", Integer.parseInt(e.getMessage()));

      Intent intentSend = new Intent(IntentCommand.INTENT_ACTION);
      intentSend.setFlags(IntentCommand.GOOGLE_CALENDAR_ADD_EVENT);
      intentSend.putExtras(bundleSend);

      mBaseService.sendBroadcast(intentSend);
      return;
    }

    // Get a response from Calendar, the response is a event entry, update cache.
    if (eventNew != null) {
      Bundle bundleSend = new Bundle();
      bundleSend.putSerializable("Data", eventNew);

      Intent intentSend = new Intent(IntentCommand.INTENT_ACTION);
      intentSend.setFlags(IntentCommand.GOOGLE_CALENDAR_ADD_EVENT);
      intentSend.putExtras(bundleSend);

      mBaseService.sendBroadcast(intentSend);
    }
  }
Beispiel #10
0
 public static Date getRandomDate(int startYear) {
   int year = startYear + (int) (Math.random() * 30);
   int month = (int) (Math.random() * 12);
   int day = (int) (Math.random() * 28);
   GregorianCalendar calendar = new GregorianCalendar(year, month, day);
   return calendar.getTime();
 }
Beispiel #11
0
  private boolean indexTableFill() {
    M_DB db = app.getDb();
    if (!db.isOpen()) {
      db.open();
    }
    GregorianCalendar calendar = new GregorianCalendar();
    long time = calendar.getTimeInMillis() / 1000;

    Random rand = new Random(time);

    for (int i = 0; i < 10; i++) {
      ContentValues cv = new ContentValues(3);
      cv.put("index_name", "ММВБ");
      cv.put("date", time - i * 1000);
      cv.put("value", rand.nextInt(10000));
      db.addRec("Indexes", cv);
      ContentValues cv1 = new ContentValues(3);
      // cv.clear();
      cv1.put("index_name", "NASDAQ");
      cv1.put("date", time - i * 1000);
      cv1.put("value", rand.nextInt(10000));
      db.addRec("Indexes", cv1);
    }
    if (db.isOpen()) {
      db.close();
    }
    return true;
  }
Beispiel #12
0
 @Override
 public Object getValue() {
   if (Versions.preHC && mType.equals("date")) {
     // We can't use the custom DateTimePicker with a sdk older than 11.
     // Fallback on the native DatePicker.
     DatePicker dp = (DatePicker) mView;
     GregorianCalendar calendar =
         new GregorianCalendar(dp.getYear(), dp.getMonth(), dp.getDayOfMonth());
     return formatDateString("yyyy-MM-dd", calendar);
   } else if (mType.equals("time")) {
     TimePicker tp = (TimePicker) mView;
     GregorianCalendar calendar =
         new GregorianCalendar(0, 0, 0, tp.getCurrentHour(), tp.getCurrentMinute());
     return formatDateString("HH:mm", calendar);
   } else {
     DateTimePicker dp = (DateTimePicker) mView;
     GregorianCalendar calendar = new GregorianCalendar();
     calendar.setTimeInMillis(dp.getTimeInMillis());
     if (mType.equals("date")) {
       return formatDateString("yyyy-MM-dd", calendar);
     } else if (mType.equals("week")) {
       return formatDateString("yyyy-'W'ww", calendar);
     } else if (mType.equals("datetime-local")) {
       return formatDateString("yyyy-MM-dd HH:mm", calendar);
     } else if (mType.equals("datetime")) {
       calendar.set(GregorianCalendar.ZONE_OFFSET, 0);
       calendar.setTimeInMillis(dp.getTimeInMillis());
       return formatDateString("yyyy-MM-dd HH:mm", calendar);
     } else if (mType.equals("month")) {
       return formatDateString("yyyy-MM", calendar);
     }
   }
   return super.getValue();
 }
Beispiel #13
0
  public static java.util.Date proximoDiaMesAtual(java.util.Date data) {
    GregorianCalendar gcTmp = new GregorianCalendar();
    gcTmp.setTime(data);
    gcTmp.add(5, 1);

    return gcTmp.getTime();
  }
 public static int[] getTimeDifference(GregorianCalendar start, GregorianCalendar stop) {
   if (start.compareTo(stop) > 0) {
     GregorianCalendar temp = start;
     start = stop;
     stop = temp;
   }
   double diff_seconds = (stop.getTimeInMillis() - start.getTimeInMillis()) / 1000.0;
   int days = 0;
   int hours = 0;
   int minutes = 0;
   int seconds = 0;
   while (diff_seconds >= 86400) {
     days++;
     diff_seconds -= 86400;
   }
   while (diff_seconds >= 3600) {
     hours++;
     diff_seconds -= 3600;
   }
   while (diff_seconds >= 60) {
     minutes++;
     diff_seconds -= 60;
   }
   seconds = (int) diff_seconds;
   int[] ret = {days, hours, minutes, seconds};
   return ret;
 }
  private void createDateEditDialog(
      int year, int month, int dayOfMonth, final Date date, final boolean isStartDate) {

    final GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(date);

    DatePickerDialog dialog =
        new DatePickerDialog(
            this,
            new DatePickerDialog.OnDateSetListener() {

              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

                gc.set(Calendar.YEAR, year);
                gc.set(Calendar.MONTH, monthOfYear);
                gc.set(Calendar.DAY_OF_MONTH, dayOfMonth);

                if (isStartDate) {
                  ponto.setStartDate(gc.getTime());
                  startDate.setText(sdfDate.format(gc.getTime()));
                } else {
                  ponto.setFinishDate(gc.getTime());
                  finishDate.setText(sdfDate.format(gc.getTime()));
                }
                repository.saveOrUpdate(ponto);
              }
            },
            year,
            month,
            dayOfMonth);
    dialog.show();
  }
 @Override
 public ConditionListVO getConditionList(GregorianCalendar start, GregorianCalendar end) {
   InVO in = new InVO(10, 10, 10, 10, 10, 10, 10);
   OutVO out = new OutVO(10, 10, 10, 10);
   ConditionListVO vo = new ConditionListVO(start.toString(), end.toString(), in, out, 30);
   return vo;
 }
 private void zeroOutTime(GregorianCalendar calendar) {
   calendar.set(GregorianCalendar.HOUR, 0);
   calendar.set(GregorianCalendar.MINUTE, 0);
   calendar.set(GregorianCalendar.SECOND, 0);
   calendar.set(GregorianCalendar.MILLISECOND, 0);
   calendar.set(GregorianCalendar.HOUR_OF_DAY, 0);
 }
  public static DateDifference getDateDifference(GregorianCalendar d1, GregorianCalendar d2) {
    DateDifference d = new DateDifference();
    // Flip Start and End if required
    if (d1.getTime().after(d2.getTime())) {
      d.end = d1;
      d.srt = d2;
    } else {
      d.end = d2;
      d.srt = d1;
    }

    // Inital Year
    int srty = d.srt.get(Calendar.YEAR);
    int endy = d.end.get(Calendar.YEAR);
    d.years = endy - srty;
    int srtm = d.srt.get(Calendar.MONTH);
    int endm = d.end.get(Calendar.MONTH);
    int srtd = d.srt.get(Calendar.DAY_OF_MONTH);
    int endd = d.end.get(Calendar.DAY_OF_MONTH);

    if (srtm > endm) {
      // A Whole years had not yet pass.
      d.years--;

      d.months = (12 - srtm) + endm;

      if (srtd > endd) {
        d.months--;

        int sdim = getDaysInMonth(srtm, srty);
        d.days = sdim - srtd + endd;
      } else {
        d.days = endd - srtd;
      }

    } else if (srtm == endm) {

      if (srtd > endd) {
        d.years--;
        d.months = 11;
        int sdim = getDaysInMonth(srtm, srty);
        d.days = sdim - srtd + endd;
      } else {
        d.months = 0;
        d.days = endd - srtd;
      }
    } else {
      d.months = 12 - endm + srtm;
      if (srtd > endd) {
        d.months--;
      }

      int sdim = getDaysInMonth(srtm, srty);
      d.days = sdim - srtd + endd;
    }

    d.absDays = (int) ((d.end.getTimeInMillis() - d.srt.getTimeInMillis()) / (86400000L)) + 1;

    return d;
  }
  private void accessBusinessCheck(UploadRequestUrl requestUrl, String password)
      throws BusinessException {
    UploadRequest request = requestUrl.getUploadRequest();
    if (!isValidPassword(requestUrl, password)) {
      throw new BusinessException(
          BusinessErrorCode.UPLOAD_REQUEST_URL_FORBIDDEN,
          "You do not have the right to get this upload request url : " + requestUrl.getUuid());
    }

    if (!(request.getStatus().equals(UploadRequestStatus.STATUS_ENABLED)
        || request.getStatus().equals(UploadRequestStatus.STATUS_CLOSED))) {
      throw new BusinessException(
          BusinessErrorCode.UPLOAD_REQUEST_READONLY_MODE,
          "The current upload request url is not available : " + requestUrl.getUuid());
    }

    Calendar now = GregorianCalendar.getInstance();
    Calendar compare = GregorianCalendar.getInstance();
    compare.setTime(request.getActivationDate());
    if (now.before(compare)) {
      throw new BusinessException(
          BusinessErrorCode.UPLOAD_REQUEST_NOT_ENABLE_YET,
          "The current upload request url is not enable yet : " + requestUrl.getUuid());
    }
    compare.setTime(request.getExpiryDate());
    if (now.after(compare)) {
      throw new BusinessException(
          BusinessErrorCode.UPLOAD_REQUEST_NOT_ENABLE_YET,
          "The current upload request url is no more available now. : " + requestUrl.getUuid());
    }
  }
Beispiel #20
0
    /** Format "EEE, dd-MMM-yy HH:mm:ss 'GMT'" for cookies */
    public void formatCookieDate(StringBuilder buf, long date) {
      gc.setTimeInMillis(date);

      int day_of_week = gc.get(Calendar.DAY_OF_WEEK);
      int day_of_month = gc.get(Calendar.DAY_OF_MONTH);
      int month = gc.get(Calendar.MONTH);
      int year = gc.get(Calendar.YEAR);
      year = year % 10000;

      int epoch = (int) ((date / 1000) % (60 * 60 * 24));
      int seconds = epoch % 60;
      epoch = epoch / 60;
      int minutes = epoch % 60;
      int hours = epoch / 60;

      buf.append(DAYS[day_of_week]);
      buf.append(',');
      buf.append(' ');
      StringUtil.append2digits(buf, day_of_month);

      buf.append('-');
      buf.append(MONTHS[month]);
      buf.append('-');
      StringUtil.append2digits(buf, year / 100);
      StringUtil.append2digits(buf, year % 100);

      buf.append(' ');
      StringUtil.append2digits(buf, hours);
      buf.append(':');
      StringUtil.append2digits(buf, minutes);
      buf.append(':');
      StringUtil.append2digits(buf, seconds);
      buf.append(" GMT");
    }
Beispiel #21
0
  /**
   * Constructs a new itinerary object with origin and destination based on flights within it.
   *
   * @param flights The list of the itineray's flights
   */
  public Itinerary(ArrayList<Flight> flights) {
    try {
      // Create new calander for departure date time for easy calculation
      // of time between arrival and departure dates.
      GregorianCalendar temp = flights.get(0).getDepartureDateTime();
      this.departureDate =
          new GregorianCalendar(
              temp.get(Calendar.YEAR), temp.get(Calendar.MONTH), temp.get(Calendar.DATE));
      this.origin = flights.get(0).getOrigin();
      this.destination = flights.get(flights.size() - 1).getDestination();
      this.flights = flights;
      this.departureDateAsStr = flights.get(0).getDepartureDateTimeAsStr().split(" ")[0];

      // cycle through all flights and get total cots and total
      // travel time without wait time
      for (Flight f : this.flights) {
        this.totalCost += f.getCost();
        this.totalTravelTime += f.calculateTravelTime();
      }

      // Calculate wait time between flights as a list of int in minutes.
      this.calculateWaitTime();
    } catch (IndexOutOfBoundsException e) {
      System.out.println("Empty list of flights given " + e.getMessage());
    }
  }
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getSelection();
    GregorianCalendar first = null;
    GregorianCalendar last = null;
    for (int i = 0; i < items.length; i++) {
      File f = (File) items[i].getData();
      Manifest mf = null;
      try {
        mf =
            ArchiveManifestCache.getInstance()
                .getManifest(
                    (AbstractIncrementalFileSystemMedium)
                        Application.getInstance().getCurrentTarget().getMedium(),
                    f);
      } catch (ApplicationException e1) {
        Application.getInstance().handleException(e1);
      }
      if (mf != null && mf.getDate() != null) {
        GregorianCalendar date = mf.getDate();
        if (first == null || date.before(first)) {
          first = date;
        }
        if (last == null || date.after(last)) {
          last = date;
        }
      }
    }

    Application.getInstance().setCurrentDates(first, last);
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   // create layout
   super.onCreate(savedInstanceState);
   setContentView(R.layout.calander_view);
   Log.v(TAG, "layout created");
   // get todays date
   GregorianCalendar userCalendar = (GregorianCalendar) GregorianCalendar.getInstance();
   // find stuff for main layout
   GridView calendar = (GridView) findViewById(R.id.calanderGridView);
   TextView month = (TextView) findViewById(R.id.calanderMonthView);
   Button back = (Button) findViewById(R.id.backMonth);
   Button forward = (Button) findViewById(R.id.forwardMonth);
   Button schedule = (Button) findViewById(R.id.addButtonView);
   Log.v(TAG, "found all elements in layout");
   // set the month to this month
   month.setText(
       theMonth(userCalendar.get(Calendar.MONTH)) + " " + userCalendar.get(Calendar.YEAR));
   Log.v(TAG, "successfully set month");
   // create grid adapter and set it
   MonthAdapter adapter = new MonthAdapter(this, userCalendar);
   calendar.setAdapter(adapter);
   Log.v(TAG, "created and added adapter");
   // add listeners
   back.setOnClickListener(new BackMonthListener(userCalendar, adapter, month));
   forward.setOnClickListener(new ForwardMonthListener(userCalendar, adapter, month));
   schedule.setOnClickListener(new ScheduleEventListener(this, adapter));
   Log.v(TAG, "set listeners");
 }
Beispiel #24
0
  public static Response setTimer(Epg epg) {
    GregorianCalendar startTime = new GregorianCalendar();
    startTime.setTimeInMillis(epg.startzeit * 1000 - Preferences.getVdr().margin_start * 60 * 1000);

    GregorianCalendar endTime = new GregorianCalendar();
    endTime.setTimeInMillis(
        epg.startzeit * 1000 + epg.dauer * 1000 + Preferences.getVdr().margin_stop * 60 * 1000);

    Timer timer = new Timer();
    timer.setChannelNumber(epg.kanal);
    timer.setStartTime(startTime);
    timer.setEndTime(endTime);
    timer.setPriority(50);
    timer.setLifetime(99);
    timer.setTitle((epg.titel == null) ? "Unknown" : epg.titel);
    timer.setDescription(AndroApplication.getAppContext().getString(R.string.app_name));
    timer.changeStateTo(Timer.VPS, Preferences.getVdr().vps);

    NEWT newt = new NEWT(timer.toNEWT());
    Response response = VDRConnection.send(newt);
    if (response.getCode() != 250) logger.error("Couldn't set timer: {}", response.getMessage());
    else {
      List<Timer> timers = TimerParser.parse(response.getMessage());
      if (timers.size() > 0) response = new R250("New timer \"" + timers.get(0).getID() + "\"");
    }
    return response;
  }
Beispiel #25
0
 public Employee(String n, double s, int year, int month, int day) {
   name = n;
   salary = s;
   GregorianCalendar calendar = new GregorianCalendar(year, month - 1, day);
   // GregorianCalendar uses 0 for January
   hireDay = calendar.getTime();
 }
  @RequestMapping(value = "/queryVisita", method = RequestMethod.POST)
  public String queryVisita(@ModelAttribute("visita") visita c, Model m, SessionStatus session)
      throws Exception {

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
    Date datum = df.parse(c.getFechaString());
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(datum);
    XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);

    /** ******************* Calling web service *********************** */
    List<Visita> lista = visitaService.traeVisita(xmlCal);
    Iterator<Visita> i = lista.iterator();
    Visita v = i.next();

    visita t =
        new visita(
            datum,
            v.getRecomendacion(),
            v.getComentarios(),
            v.getRfc(),
            v.getLote(),
            v.getParcela(),
            v.getProductor(),
            v.getAsesor());

    List<Maleza> malezas = malezaService.traeMalezas(xmlCal);

    Iterator<Maleza> j = malezas.iterator();
    listaMalezas.clear();
    while (j.hasNext()) {
      Maleza mal = j.next();
      maleza esta = new maleza(datum, mal.getNombre(), mal.getPoblacion());
      listaMalezas.add(esta);
    }

    List<Plaga> plagas = plagaService.traePlaga(xmlCal);
    Iterator<Plaga> k = plagas.iterator();
    listaPlagas.clear();
    while (k.hasNext()) {
      Plaga p = k.next();
      maleza dieser = new maleza(datum, p.getNombre(), p.getPoblacion());
      listaPlagas.add(dieser);
    }

    List<Enfermedad> sicks = enfermedadService.traeEnfermedades(xmlCal);
    listaSick.clear();
    Iterator<Enfermedad> l = sicks.iterator();
    while (l.hasNext()) {
      Enfermedad sick = l.next();
      listaSick.add(sick.getEnfermedad());
    }

    m.addAttribute("visitaForm", t);
    m.addAttribute("malezas", listaMalezas);
    m.addAttribute("plagas", listaPlagas);
    m.addAttribute("enfermedades", listaSick);

    return "redirect:informesDone";
  }
Beispiel #27
0
 private Date getNextYearFor(Date date) {
   GregorianCalendar previousYearToDate = new GregorianCalendar();
   previousYearToDate.setTime(date);
   int prevYear = previousYearToDate.get(Calendar.YEAR) + 1;
   previousYearToDate.set(Calendar.YEAR, prevYear);
   return previousYearToDate.getTime();
 }
 private void setTimeStamp(GregorianCalendar c, Date d) {
   SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
   String datum = df.format(d);
   c.set(Calendar.YEAR, 2000 + Integer.valueOf(datum.substring(1, 4)));
   c.set(Calendar.MONTH, Integer.valueOf(datum.substring(6, 7)) - 1);
   c.set(Calendar.DAY_OF_MONTH, Integer.valueOf(datum.substring(9)));
 }
Beispiel #29
0
 /** @tests java.util.Date#Date() */
 public void test_Constructor() {
   // Test for method java.util.Date()
   GregorianCalendar gc = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9);
   long oldTime = gc.getTime().getTime();
   long now = new Date().getTime();
   assertTrue("Created incorrect date: " + oldTime + " now: " + now, oldTime < now);
 }
Beispiel #30
0
  public void updateCalendar(Date date, Date fromHour, Date toHour) {
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTime(date);
    int day = cal.get(Calendar.DAY_OF_WEEK);
    DayEnum dayEnum = null;
    if (Calendar.MONDAY == day) {
      dayEnum = DayEnum.MONDAY;
    }
    if (Calendar.TUESDAY == day) {
      dayEnum = DayEnum.TUESDAY;
    }
    if (Calendar.WEDNESDAY == day) {
      dayEnum = DayEnum.WEDNESDAY;
    }
    if (Calendar.THURSDAY == day) {
      dayEnum = DayEnum.THURSDAY;
    }
    if (Calendar.FRIDAY == day) {
      dayEnum = DayEnum.FRIDAY;
    }
    if (Calendar.SUNDAY == day) {
      dayEnum = DayEnum.SUNDAY;
    }
    if (Calendar.SATURDAY == day) {
      dayEnum = DayEnum.SATURDAY;
    }

    for (DayRange dayRange : calendar) {

      if (dayRange.getDayEnum().equals(dayEnum)) {
        dayRange.setRange(fromHour, toHour);
        dayRange.save();
      }
    }
  }