Exemplo n.º 1
1
 private String getDate(String timeStampStr, String format) {
   DateFormat formatter = new SimpleDateFormat(format);
   long timeStamp = Long.parseLong(timeStampStr);
   Calendar calendar = Calendar.getInstance();
   calendar.setTimeInMillis(timeStamp);
   return formatter.format(calendar.getTime());
 }
Exemplo n.º 2
0
 public void parse(String s) throws JDOMException, IOException {
   docIn = new StringReader(s);
   System.out.println(s);
   SAXBuilder builder = new SAXBuilder();
   Document doc = builder.build(docIn);
   Element root = doc.getRootElement();
   // getting channel descriptor and rebuilding it
   Element chDesc = root;
   // .getChild("desc");
   // getting Channel Name
   // FIXME: there's a bug ...this a workaround.
   Element chName = chDesc.getChild("name");
   if (chName == null) {
     chDesc = root.getChild("desc");
     chName = chDesc.getChild("name");
   }
   channelName = new String(chName.getText());
   // getting channel topic
   Element chTopic = chDesc.getChild("topic");
   Element pipeUri = chDesc.getChild("pipeID");
   pipeURI = new String(pipeUri.getText());
   channelTopic = new String(chTopic.getText());
   Element chDateTime = chDesc.getChild("timestamp");
   nanotime = Long.parseLong(chDateTime.getText().trim());
   Element chFounder = chDesc.getChild("founder");
   if (chFounder == null) return;
   founderName = chFounder.getChildText("name");
   founderAddress = chFounder.getChildText("email");
   founderPeerID = chFounder.getChildText("peerid");
   Element userListItem = root.getChild("userlist");
   if (userListItem == null) return;
   List userList = userListItem.getChildren();
   for (Object o : userList) {
     Element e = (Element) o;
     UserInfo infoItem = mkUserInfo(e);
     chUsers.put(infoItem.getAddress(), infoItem);
   }
 }
Exemplo n.º 3
0
 private Element mkTimeStampXML() {
   nanotime = System.currentTimeMillis();
   Element timestamp = new Element("timestamp").setText(Long.toString(nanotime));
   return timestamp;
 }