Esempio n. 1
0
  private void jButton2ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:
    try {
      String id = jTextField1.getText();
      Integer idMul = Integer.parseInt(id);
      GestorMultas gm = new GestorMultas();

      Calendar venc = Calendar.getInstance();
      Calendar actual = Calendar.getInstance();

      // Recupero fecha de DB
      Multa esta = gm.buscarmultas(idMul);
      venc.setTime(esta.getFecha_vencimiento());

      // Fecha Actaul
      CeViSy ahora = new CeViSy();
      actual.setTime(ahora.calcfecha());

      long milisven = venc.getTimeInMillis();
      long milisact = actual.getTimeInMillis();

      // se calcula la diferencia de milisegundos entre ambas fechas
      long diff = milisact - milisven;

      // Para calcular la diferencia en segundos
      long diffSeconds = diff / 1000;

      // Para calcular la diferencia en minutos
      long diffMinutes = diff / (60 * 1000);

      // Para calcular la diferencia en horas
      long diffHours = diff / (60 * 60 * 1000);

      // Para calcular la diferencia en dias
      long diffDays = diff / (24 * 60 * 60 * 1000);
      Integer dias = Integer.valueOf(String.valueOf(diffDays));

      jTextField4.setText(dias.toString());
    } catch (DateAccessException e) {
      System.out.println(e);
    }
  } // GEN-LAST:event_jButton2ActionPerformed
  // Method:
  private void populateData() {

    textpadSeq_ = new RCT.TextpadMsgHistSeqHolder();
    data_ = new Object[0][0];

    if (ARCH_SEL_TODAY == selectionType_) {

      // Get today's date
      Date now = new Date();
      Calendar cal = Calendar.getInstance();
      cal.setTime(now);
      int day = cal.get(Calendar.DAY_OF_MONTH);
      int month = cal.get(Calendar.MONTH) + 1;
      int year = cal.get(Calendar.YEAR);

      String fromDate = year + "-" + month + "-" + day + " 00:00:00";

      String toDate = year + "-" + month + "-" + day + " 23:59:59";

      try {

        TeamModule.getTextpadArchiveTimeRange(className_, teamName_, fromDate, toDate, textpadSeq_);
      } catch (RCT.TeamServerPackage.DataSelectionExceedsLimit dsel) {

        JOptionPane.showMessageDialog(
            SessionModule.getFrame(),
            LangModule.i18n.getString("ExceptionDialog3"),
            LangModule.i18n.getString("ExceptionDialog1"),
            JOptionPane.WARNING_MESSAGE);
        return;
      }
    } else if (ARCH_SEL_TIMERANGE == selectionType_) {

      try {

        TeamModule.getTextpadArchiveTimeRange(
            className_, teamName_, fromDate_, toDate_, textpadSeq_);
      } catch (RCT.TeamServerPackage.DataSelectionExceedsLimit dsel) {

        JOptionPane.showMessageDialog(
            SessionModule.getFrame(),
            LangModule.i18n.getString("ExceptionDialog3"),
            LangModule.i18n.getString("ExceptionDialog1"),
            JOptionPane.WARNING_MESSAGE);
        return;
      }
    }

    // Check if we received any textpads
    if (0 < textpadSeq_.value.length) {

      data_ = new Object[textpadSeq_.value.length][TEXTPAD_N_FIELDS];

      for (int i = 0; i < textpadSeq_.value.length; i++) {

        data_[i][TEXTPAD_ID] = textpadSeq_.value[i].id;
        data_[i][TEXTPAD_NAME] = textpadSeq_.value[i].name;
        data_[i][TEXTPAD_DATE] = Utility.getDateAndTime(textpadSeq_.value[i].date);
      }
    }
  }