Exemplo n.º 1
0
    String replaceTimestamp(String strLine) {
      if (timestamp == null) return strLine; // no timestamp was specified at constructor.

      if (strLine.contains(TIMESTAMP_TAG)
          && tsIndex < ts.size()) { // ts is timestamp array, each next timestamp gets next value
        StringBuffer sb = new StringBuffer(strLine);
        String tsStr = ts.get(tsIndex++);
        int p1 = sb.indexOf("value=\"") + 7;
        int p2 = sb.indexOf("\"", p1);
        String strLine2 = sb.replace(p1, p2, "0x" + tsStr).toString();
        System.out.println(">>> replaced Event-Timestamp :  " + strLine + " => " + strLine2);
        return strLine2;
      }
      return strLine; // default
    }
Exemplo n.º 2
0
    List<String> calc(String str_date) {
      long myDateMillis = 0;
      long d1900 = 0;
      Date myDate = null;
      List<String> ls = new ArrayList<String>();
      try {

        myDate = parseDate(str_date);
        System.out.println(printDate(myDate) + " // orig date");
        //
        Calendar cal = Calendar.getInstance();

        cal.setTime(myDate);
        cal.add(Calendar.HOUR, -5);
        cal.add(Calendar.MINUTE, -30);
        myDate = cal.getTime(); // Update date to -5:30
        //
        Calendar c = Calendar.getInstance();
        c.clear();
        c.setTimeZone(TimeZone.getTimeZone("GMT"));
        c.set(1900, 0, 1, 0, 0, 0);
        d1900 = c.getTimeInMillis();
        System.out.println(printDate(c.getTime()) + " // 1900");

        for (int i = 0; i < 10; i++) {
          long durInSec = (cal.getTimeInMillis() - d1900) / 1000;
          String durInSecHex = Long.toHexString(durInSec);
          System.out.println(printDate(cal.getTime()) + " " + durInSec + " " + durInSecHex);
          ls.add(durInSecHex);
          cal.add(Calendar.SECOND, +50);
        }

      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return ls;
    } // DateCalc constructor