Exemplo n.º 1
0
  public List<MersVO> mersData() {
    List<MersVO> list = new ArrayList<MersVO>();
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d");
    StringTokenizer st = new StringTokenizer(sdf.format(date), "-");
    int year = Integer.parseInt(st.nextToken());
    int month = Integer.parseInt(st.nextToken());
    int day = Integer.parseInt(st.nextToken());
    try {
      Document doc = Jsoup.connect("http://www.cdc.go.kr/CDC/cms/content/15/63315_view.html").get();
      // System.out.println(doc);
      Elements trs = doc.select("table tbody tr");
      // System.out.println(trs);
      String data = "";
      String[] temp = {"panel panel-primary", "panel panel-green", "panel panel-yellow"};
      int i = 0;
      for (Element tr : trs) {
        Iterator<Element> it = tr.getElementsByTag("td").iterator();

        // if(i==2) break;
        while (it.hasNext()) {

          MersVO vo = new MersVO();
          vo.setType(it.next().text());
          vo.setMers(it.next().text().replace("*", ""));
          /*vo.setYsum(it.next().text().replace(",", ""));
          vo.setPlus(it.next().text());
          vo.setMinus(it.next().text());*/

          if (data.equals("")) {
            data = it.next().text();
            vo.setIng(data);
          } else {
            vo.setIng(data);
          }
          vo.setNsum(it.next().text().replace(",", ""));
          vo.setHouse(it.next().text());
          vo.setOffice(it.next().text());
          vo.setDis(it.next().text().replace(",", ""));
          vo.setDiv1(temp[i]);
          vo.setYear(year);
          vo.setMonth(month);
          if (i == 2) {
            vo.setDay(day - 1);
          } else {
            vo.setDay(day);
          }
          list.add(vo);
          i++;
        }
      }
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
    return list;
  }
  private void saveData(TelemetryData data) {
    PrintWriter out;
    boolean newFile = false;

    if (saveCnt > 25000) {
      File logFile;
      int i;

      logFile = new File(telemetryDir + 99 + ".log");
      logFile.delete();
      newFile = true;

      for (i = 99; i > 0; i--) {
        logFile = new File(telemetryDir + (i - 1) + ".log");
        logFile.renameTo(new File(telemetryDir + i + ".log"));
      }
      saveCnt = 0;
    }

    try {
      String text = "";
      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.GERMAN);

      saveCnt++;
      out = new PrintWriter(new FileOutputStream(telemetryDir + "0.log", true));
      if (newFile) {
        text =
            "Time\tLatitude\tLongitude\tSpeed\tAcceleration X\tAcceleration Y\tAcceleration Z\tCoG\tOrientation Y\tOrientation Z\n\n";
        out.print(text);
      }
      text = dateFormat.format(new Date(System.currentTimeMillis())) + "\t";
      if (posValid) text = text + lastLat + "\t" + lastLon + "\t" + m_lastSpeed + "\t";
      else text = text + "-\t-\t-\t";
      text =
          text
              + data.getAccelX()
              + "\t"
              + data.getAccelY()
              + "\t"
              + data.getAccelZ()
              + "\t"
              + data.CoG
              + "\t"
              + data.getOrientY()
              + "\t"
              + data.getOrientZ()
              + "\n\n";
      out.print(text);
      out.close();
    } catch (IOException ioe) {
    }
  }
Exemplo n.º 3
0
 /** Sets the time of the next scheduled raid */
 private void setNextRaid(Info info) {
   String raidTime = info.getMessage().substring(13);
   raidTime = substituteTimeZone(raidTime);
   try {
     SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm z");
     Date date = parser.parse(raidTime);
     TimeZone z = parser.getTimeZone();
     GregorianCalendar cal = new GregorianCalendar(z);
     cal.setTime(date);
     raids.put(info.getChannel(), cal);
     saveRaids();
     info.sendMessage("Raid time set.");
   } catch (ParseException e) {
     info.sendMessage(
         "Date format was bad.  Date format is like \"2008-11-26 21:45 EST\".  You entered "
             + raidTime);
   }
 }
Exemplo n.º 4
0
  private void nextRaid(Info info) {
    GregorianCalendar nextRaid = raids.get(info.getChannel());
    GregorianCalendar now = Utils.getRealDate(info);
    int diffMins = (int) ((nextRaid.getTimeInMillis() - now.getTimeInMillis()) / 1000 / 60);
    if (nextRaid.compareTo(now) < 0) {
      info.sendMessage("There is no future raid set.");
      return;
    }
    String tz = info.getMessage().substring(9).trim();
    tz = substituteTimeZone(tz);
    TimeZone timeZone;
    if (tz.length() == 0) timeZone = tZF("GMT");
    else timeZone = tZF(tz);
    formatter.setTimeZone(timeZone);

    String ret = "The next raid is scheduled for " + formatter.format(nextRaid.getTime());
    ret = ret + getTimeDifference(diffMins);
    info.sendMessage(ret);
  }
Exemplo n.º 5
0
Arquivo: Macro.java Projeto: bramk/bnd
  public String _tstamp(String args[]) {
    String format = "yyyyMMddHHmm";
    long now = System.currentTimeMillis();
    TimeZone tz = TimeZone.getTimeZone("UTC");

    if (args.length > 1) {
      format = args[1];
    }
    if (args.length > 2) {
      tz = TimeZone.getTimeZone(args[2]);
    }
    if (args.length > 3) {
      now = Long.parseLong(args[3]);
    }
    if (args.length > 4) {
      domain.warning("Too many arguments for tstamp: " + Arrays.toString(args));
    }

    SimpleDateFormat sdf = new SimpleDateFormat(format);
    sdf.setTimeZone(tz);

    return sdf.format(new Date(now));
  }
Exemplo n.º 6
0
  public static void main(String argv[]) throws Exception {
    int i, start, end;
    ;
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy hh:mm:ss a");
    GregorianCalendar cal = new GregorianCalendar();
    SmbFile f;

    if (argv.length < 2) {
      throw new IllegalArgumentException("usage: FileInfo <url> <opindex>");
    }

    if (argv.length == 3) {
      SmbFile tmp = new SmbFile(argv[0]);
      f = new SmbFile(tmp.toString(), argv[1]);
      start = Integer.parseInt(argv[2]);
    } else {
      f = new SmbFile(argv[0]);
      start = Integer.parseInt(argv[1]);
    }

    sdf.setCalendar(cal);

    i = end = start;
    do {
      switch (i) {
        case 0:
          System.out.println("        toString: " + f.toString());
          break;
        case 1:
          System.out.println("           toURL: " + f.toURL());
          break;
        case 2:
          System.out.println("         getName: " + f.getName());
          break;
        case 3:
          System.out.println("          length: " + f.length());
          break;
        case 4:
          System.out.println(" getLastModified: " + sdf.format(new Date(f.getLastModified())));
          break;
        case 5:
          System.out.println("        isHidden: " + f.isHidden());
          break;
        case 6:
          System.out.println("          isFile: " + f.isFile());
          break;
        case 7:
          System.out.println("     isDirectory: " + f.isDirectory());
          break;
        case 8:
          System.out.println("        hashCode: " + f.hashCode());
          break;
        case 9:
          System.out.println("      getUncPath: " + f.getUncPath());
          break;
        case 10:
          System.out.println("         getType: " + TYPES[f.getType()]);
          break;
        case 11:
          System.out.println("        getShare: " + f.getShare());
          break;
        case 12:
          System.out.println("       getServer: " + f.getServer());
          break;
        case 13:
          System.out.println("         getPath: " + f.getPath());
          break;
        case 14:
          System.out.println("       getParent: " + f.getParent());
          break;
        case 15:
          System.out.println("    lastModified: " + sdf.format(new Date(f.lastModified())));
          break;
        case 16:
          System.out.println("getDiskFreeSpace: " + f.getDiskFreeSpace());
          break;
        case 17:
          System.out.println("         getDate: " + sdf.format(new Date(f.getDate())));
          break;
        case 18:
          System.out.println("getContentLength: " + f.getContentLength());
          break;
        case 19:
          System.out.println("getCanonicalPath: " + f.getCanonicalPath());
          break;
        case 20:
          System.out.println("          exists: " + f.exists());
          break;
        case 21:
          System.out.println("         canRead: " + f.canRead());
          break;
        case 22:
          System.out.println("        canWrite: " + f.canWrite());
          break;
        case 23:
          ACE[] security = f.getSecurity(true);
          System.out.println("        Security:");
          for (int ai = 0; ai < security.length; ai++) {
            System.out.println(security[ai].toString());
          }
          System.out.println("       Share Perm:");
          security = f.getShareSecurity(true);
          for (int ai = 0; ai < security.length; ai++) {
            System.out.println(security[ai].toString());
          }
          break;
        case 24:
          System.out.println("      getDfsPath: " + f.getDfsPath());
          break;
      }
      i++;
      if (i == 25) {
        i = 0;
      }
    } while (i != end);
  }
Exemplo n.º 7
0
  public List getIterationList(String projectId) {
    List<Map> list = new ArrayList<Map>();

    try {

      String apiUrl =
          rallyApiHost
              + "/iteration?"
              + "project="
              + rallyApiHost
              + "/project/"
              + projectId
              + "&fetch=true&order=Name%20desc&start=1&pagesize=100";

      String checkProjectRef = rallyApiHost + "/project/" + projectId;

      log.info("rallyApiUrl:" + apiUrl);
      log.info("checkProjectRef:" + checkProjectRef);

      String responseXML = getRallyXML(apiUrl);

      SimpleDateFormat ISO8601FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
      Date currentDate = new Date();

      org.jdom.input.SAXBuilder bSAX = new org.jdom.input.SAXBuilder();
      org.jdom.Document doc = bSAX.build(new StringReader(responseXML));
      Element root = doc.getRootElement();

      XPath xpath = XPath.newInstance("//Object");
      List xlist = xpath.selectNodes(root);

      Iterator iter = xlist.iterator();
      while (iter.hasNext()) {

        Map map = new HashMap();

        Element item = (Element) iter.next();
        String objId = item.getChildText("ObjectID");
        String name = item.getChildText("Name");
        String state = item.getChildText("State");

        String startDateStr = item.getChildText("StartDate");
        String endDateStr = item.getChildText("EndDate");

        Date startDate = ISO8601FORMAT.parse(startDateStr);
        Date endDate = ISO8601FORMAT.parse(endDateStr);

        boolean isCurrent = false;

        int startCheck = startDate.compareTo(currentDate);
        int endCheck = endDate.compareTo(currentDate);

        if (startCheck < 0 && endCheck > 0) {
          isCurrent = true;
        }

        log.info("name=" + name + " isCurrent=" + isCurrent);

        String releaseRef = item.getAttribute("ref").getValue();

        // In child project, parent object have to be filiered
        Element projectElement = item.getChild("Project");
        String projectRef = projectElement.getAttributeValue("ref");

        if (projectRef.equals(checkProjectRef)) {

          map.put("objId", objId);
          map.put("rallyRef", releaseRef);
          map.put("name", name);
          map.put("state", state);
          map.put("isCurrent", "" + isCurrent);

          list.add(map);
        }
      }

      log.info("-----------");

    } catch (Exception ex) {
      log.error("ERROR: ", ex);
    }

    return list;
  }
Exemplo n.º 8
0
 private String formatDate(Date myDate) {
   String strFormat = "yyyy-MM-dd HH:mm:ss";
   SimpleDateFormat formatter = new SimpleDateFormat(strFormat);
   String strDate = formatter.format(myDate);
   return strDate;
 }