Exemple #1
0
  /**
   * 현재날짜(System TimeZone 및 Locale 기준)에서 몇일 전,후의 날짜를 구한다.
   *
   * @param day 변경할 일수
   * @return 현재날짜에서 입력한 일수를 계산한 날짜(yyyyMMdd)
   */
  public static String getDateWithSpan(long day) {
    SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");

    java.util.Date date = new java.util.Date();
    java.util.Date spanDate = new java.util.Date(date.getTime() + (day * 1000 * 60 * 60 * 24));

    return fmt.format(spanDate);
  }
Exemple #2
0
 public void gather(
     String dbase,
     String table1,
     String table2,
     String table3,
     String field1,
     String field2,
     String field3) {
   this.dbase = dbase;
   this.table1 = table1;
   this.table2 = table2;
   this.table3 = table3;
   this.field1 = field1;
   this.field2 = field2;
   this.field3 = field3;
   nseer_db db = new nseer_db(dbase);
   SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
   java.util.Date now = new java.util.Date();
   try {
     String sql3 = "delete from " + table1 + "";
     db.executeUpdate(sql3);
     String sql = "select * from " + table2 + " where tag='1'";
     rs = db.executeQuery(sql);
     int i = 0;
     while (rs.next()) {
       idgroup[i] = rs.getString(field1);
       alarmgroup[i] = rs.getString(field2);
       i++;
     }
     for (int j = 0; j < i; j++) {
       java.util.Date date1 = new java.util.Date();
       long Time = (now.getTime() / 1000) - 60 * 60 * 24 * Integer.parseInt(alarmgroup[j]);
       date1.setTime(Time * 1000);
       String time = formatter.format(date1);
       sql1 =
           "select * from "
               + table3
               + " where "
               + field1
               + "='"
               + idgroup[j]
               + "'&&"
               + field3
               + "<='"
               + time
               + "'&&tag='0'";
       rs1 = db.executeQuery(sql1);
       while (rs1.next()) {
         java.util.Date date2 = formatter.parse(rs1.getString(field3));
         long days = (long) ((date1.getTime() - date2.getTime()) / (1000 * 60 * 60 * 24) + 0.5);
         String sql2 =
             "insert into "
                 + table1
                 + "("
                 + field1
                 + ",ordernum,sumtotal,invoicetime,"
                 + field2
                 + ",days) values('"
                 + idgroup[j]
                 + "','"
                 + rs1.getString("ordernum")
                 + "','"
                 + rs1.getString("sumtotal")
                 + "','"
                 + rs1.getString(field3)
                 + "','"
                 + alarmgroup[j]
                 + "','"
                 + days
                 + "')";
         db.executeUpdate(sql2);
       }
     }
     db.close();
   } catch (Exception ex) {
   }
 }