Пример #1
0
  public List<Login> findUserPswdExpYesterday() {
    log.debug("findUserPswdExpToday: findUserNearPswdExp called.");

    java.sql.Date expDate = new java.sql.Date(System.currentTimeMillis());
    java.sql.Date endDate = new java.sql.Date(expDate.getTime());

    Calendar c = Calendar.getInstance();
    c.add(Calendar.DAY_OF_YEAR, 1);
    c.setTime(expDate);
    expDate.setTime(c.getTimeInMillis());

    c.add(Calendar.DAY_OF_YEAR, 1);
    endDate.setTime(c.getTimeInMillis());

    log.debug("dates between : " + expDate.toString() + " " + endDate.toString());

    String sql =
        new String(
            " from org.openiam.idm.srvc.auth.dto.Login l where "
                + " l.pwdExp BETWEEN :startDate and :endDate");

    Session session = sessionFactory.getCurrentSession();
    Query qry = session.createQuery(sql);
    qry.setDate("startDate", expDate);
    qry.setDate("endDate", endDate);

    List<Login> results = (List<Login>) qry.list();
    if (results == null) {
      return (new ArrayList<Login>());
    }
    return results;
  }
 public Object set(Object o, DateWritable d) {
   if (d == null) {
     return null;
   }
   ((Date) o).setTime(d.get().getTime());
   return o;
 }
 public Object set(Object o, Date value) {
   if (value == null) {
     return null;
   }
   ((Date) o).setTime(value.getTime());
   return o;
 }
Пример #4
0
 public static String formatDate(long time) {
   if (format == null) {
     format = new SimpleDateFormat("yyyy-MM-dd");
   }
   if (date == null) {
     date = new Date(0);
   }
   date.setTime(time);
   return format.format(date);
 }
 protected void evaluateString(ColumnVector columnVector, LongColumnVector output, int i) {
   BytesColumnVector bcv = (BytesColumnVector) columnVector;
   text.set(bcv.vector[i], bcv.start[i], bcv.length[i]);
   try {
     date.setTime(formatter.parse(text.toString()).getTime());
     output.vector[i] = baseDate - DateWritable.dateToDays(date);
   } catch (ParseException e) {
     output.vector[i] = 1;
     output.isNull[i] = true;
   }
 }
  public static void getTimestampString(StringBuffer sb, long seconds, int nanos, int scale) {

    synchronized (sdfts) {
      tempDate.setTime(seconds * 1000);
      sb.append(sdfts.format(tempDate));

      if (scale > 0) {
        sb.append('.');
        sb.append(StringUtil.toZeroPaddedString(nanos, 9, scale));
      }
    }
  }
  public void displayProduct() {
    this.productBeanList = new ArrayList<ProductBean>();
    String modele = null;

    java.util.Date uDate =
        new java.util.Date(
            System
                .currentTimeMillis()); // Relever l'heure avant le debut du progamme (en
                                       // milliseconde)
    System.out.println("Debut de la recherche de la liste des produits");
    List<Product> _productList = this.globalService.getProductsRecordables(modele);
    System.out.println("Fin de la recherche de la liste des produits");
    Date dateFin =
        new Date(
            System.currentTimeMillis()); // Relever l'heure a la fin du progamme (en milliseconde)
    Date duree = new Date(System.currentTimeMillis()); // Pour calculer la différence
    duree.setTime(dateFin.getTime() - uDate.getTime()); // Calcul de la différence
    long secondes = duree.getTime() / 1000;
    long min = secondes / 60;
    long heures = min / 60;
    long mili = duree.getTime() % 1000;
    secondes %= 60;
    System.out.println(
        "Temps passé durant le traitement : \nHeures : "
            + heures
            + "\nMinutes : "
            + min
            + "\nSecondes : "
            + secondes
            + "\nMilisecondes : "
            + mili
            + "\n");

    for (Product p : _productList) {

      ProductBean _productBean = new ProductBean();

      _productBean.setIdProduct(p.getIdProduct()); // JB : cette ligne ne semble pas servir
      _productBean.setSerialNumber(p.getSerialNumber());
      _productBean.setProductConf(p.getFEDDProductConf());
      _productBean.setDatecode(p.getDatecode());
      // _productBean.getProductConf().setReference(p.getProductConf().getReference()); en
      // commentaire par RMO

      this.productBeanList.add(_productBean);
    }
    System.out.println("Fin de la recuperation des informations produits");
    this.result = true;
  }
  @Override
  public void evaluate(VectorizedRowBatch batch) {

    if (childExpressions != null) {
      super.evaluateChildren(batch);
    }

    LongColumnVector outV = (LongColumnVector) batch.cols[outputColumn];
    ColumnVector inputCol = batch.cols[this.colNum];
    /* every line below this is identical for evaluateLong & evaluateString */
    final int n = inputCol.isRepeating ? 1 : batch.size;
    int[] sel = batch.selected;

    if (batch.size == 0) {
      /* n != batch.size when isRepeating */
      return;
    }

    /* true for all algebraic UDFs with no state */
    outV.isRepeating = inputCol.isRepeating;

    switch (inputTypes[0]) {
      case DATE:
        baseDate = (int) longValue;
        break;

      case TIMESTAMP:
        date.setTime(longValue / 1000000);
        baseDate = DateWritable.dateToDays(date);
        break;

      case STRING:
        try {
          date.setTime(formatter.parse(new String(stringValue, "UTF-8")).getTime());
          baseDate = DateWritable.dateToDays(date);
          break;
        } catch (Exception e) {
          outV.noNulls = false;
          if (batch.selectedInUse) {
            for (int j = 0; j < n; j++) {
              int i = sel[j];
              outV.isNull[i] = true;
            }
          } else {
            for (int i = 0; i < n; i++) {
              outV.isNull[i] = true;
            }
          }
          return;
        }
    }

    switch (inputTypes[1]) {
      case DATE:
        if (inputCol.noNulls) {
          outV.noNulls = true;
          if (batch.selectedInUse) {
            for (int j = 0; j < n; j++) {
              int i = sel[j];
              outV.vector[i] = evaluateDate(inputCol, i);
            }
          } else {
            for (int i = 0; i < n; i++) {
              outV.vector[i] = evaluateDate(inputCol, i);
            }
          }
        } else {
          // Handle case with nulls. Don't do function if the value is null, to save time,
          // because calling the function can be expensive.
          outV.noNulls = false;
          if (batch.selectedInUse) {
            for (int j = 0; j < n; j++) {
              int i = sel[j];
              outV.isNull[i] = inputCol.isNull[i];
              if (!inputCol.isNull[i]) {
                outV.vector[i] = evaluateDate(inputCol, i);
              }
            }
          } else {
            for (int i = 0; i < n; i++) {
              outV.isNull[i] = inputCol.isNull[i];
              if (!inputCol.isNull[i]) {
                outV.vector[i] = evaluateDate(inputCol, i);
              }
            }
          }
        }
        break;

      case TIMESTAMP:
        if (inputCol.noNulls) {
          outV.noNulls = true;
          if (batch.selectedInUse) {
            for (int j = 0; j < n; j++) {
              int i = sel[j];
              outV.vector[i] = evaluateTimestamp(inputCol, i);
            }
          } else {
            for (int i = 0; i < n; i++) {
              outV.vector[i] = evaluateTimestamp(inputCol, i);
            }
          }
        } else {
          // Handle case with nulls. Don't do function if the value is null, to save time,
          // because calling the function can be expensive.
          outV.noNulls = false;
          if (batch.selectedInUse) {
            for (int j = 0; j < n; j++) {
              int i = sel[j];
              outV.isNull[i] = inputCol.isNull[i];
              if (!inputCol.isNull[i]) {
                outV.vector[i] = evaluateTimestamp(inputCol, i);
              }
            }
          } else {
            for (int i = 0; i < n; i++) {
              outV.isNull[i] = inputCol.isNull[i];
              if (!inputCol.isNull[i]) {
                outV.vector[i] = evaluateTimestamp(inputCol, i);
              }
            }
          }
        }
        break;

      case STRING:
        if (inputCol.noNulls) {
          outV.noNulls = true;
          if (batch.selectedInUse) {
            for (int j = 0; j < n; j++) {
              int i = sel[j];
              evaluateString(inputCol, outV, i);
            }
          } else {
            for (int i = 0; i < n; i++) {
              evaluateString(inputCol, outV, i);
            }
          }
        } else {
          // Handle case with nulls. Don't do function if the value is null, to save time,
          // because calling the function can be expensive.
          outV.noNulls = false;
          if (batch.selectedInUse) {
            for (int j = 0; j < n; j++) {
              int i = sel[j];
              outV.isNull[i] = inputCol.isNull[i];
              if (!inputCol.isNull[i]) {
                evaluateString(inputCol, outV, i);
              }
            }
          } else {
            for (int i = 0; i < n; i++) {
              outV.isNull[i] = inputCol.isNull[i];
              if (!inputCol.isNull[i]) {
                evaluateString(inputCol, outV, i);
              }
            }
          }
        }
        break;
    }
  }
 protected int evaluateTimestamp(ColumnVector columnVector, int index) {
   LongColumnVector lcv = (LongColumnVector) columnVector;
   date.setTime(lcv.vector[index] / 1000000);
   return baseDate - DateWritable.dateToDays(date);
 }