Exemplo n.º 1
0
 public static void autoTime() {
   String pattern = "yyyy-MM-dd HH:mm:ss";
   SimpleDateFormat sdf = new SimpleDateFormat(pattern);
   // Parse a sample date starting at position 0.
   Calendar testTime = Calendar.getInstance();
   String text = "2011-8-3 22:18:00";
   testTime.setTime(sdf.parse(text, new ParsePosition(0)));
   Calendar testTime1 = Calendar.getInstance();
   String text1 = "2011-8-3 22:19:00";
   testTime1.setTime(sdf.parse(text1, new ParsePosition(0)));
   long f = testTime.getTimeInMillis() - testTime1.getTimeInMillis();
   int inter = testTime.compareTo(testTime1);
   Date now = Calendar.getInstance().getTime();
   int year = now.getYear() + 1900;
   int month = now.getMonth() + 1;
   int day = now.getDate();
   int hour = now.getHours();
   int minute = now.getMinutes();
   int second = now.getSeconds();
 }
Exemplo n.º 2
0
  /** Updates all train data and refreshes the GUI. */
  public static void timeTick(Date date, int delta) {
    if (!isPaused) {
      refreshUI += delta;
      double time = date.getHours() * 60 * 60 + date.getMinutes() * 60 + date.getSeconds();

      for (int i = 0; i < trainList.size(); i++) {
        // Update the data for each train.
        boolean isSelectedByTNC = false;
        if (!isSolo) {
          isSelectedByTNC = tncUI.uiSelect(trainList.get(i).id);
        }
        trainList.get(i).timeTick(time, ((double) (delta)) / 1000.0, isSolo, isSelectedByTNC);
      }

      if (refreshUI >= 1000) {
        // Refresh the train module GUI.

        if (isSolo) {
          // If TNM is running solo, figure out the new time.
          soloTime += 1;
          if (soloTime >= 24 * 60 * 60) {
            soloTime = soloTime % (24 * 60 * 60);
          }
          int hrs = (int) soloTime / (60 * 60);
          int min = ((int) soloTime / 60) % 60;
          int sec = (int) soloTime - (hrs * 60 * 60 + min * 60);
          soloDate = new Date(93, 2, 2, hrs, min, sec);
        } else {
          soloTime = time;
        }

        refreshUI = refreshUI % 1000;
        setSelectedId(selectedId);
      }
    }
  }
Exemplo n.º 3
0
 public boolean write() {
   try {
     Properties configFile = new Properties();
     configFile.load(new FileInputStream(settingsFile));
     configFile.put("SMTP_Host", mSMTPHost);
     configFile.put("SMTP_Port", mSMTPPort);
     configFile.put("POP3_Host", mPOP3Host);
     configFile.put("POP3_Port", mPOP3Port);
     configFile.put("From", mFrom);
     configFile.put("Password", mPass);
     configFile.put("Name", mName);
     configFile.put("Mails_Location", mMailsLocation);
     configFile.put("Contacts_Location", mContactsLocation);
     // TODO : There are some wrong and deprecated usage of date formatting, fix it.
     configFile.put(
         "Last_Update",
         Integer.toString(mLastUpdate.getYear() + 1900)
             + "/"
             + Integer.toString(mLastUpdate.getMonth())
             + "/"
             + Integer.toString(mLastUpdate.getDay())
             + "-"
             + Integer.toString(mLastUpdate.getHours())
             + "-"
             + Integer.toString(mLastUpdate.getMinutes())
             + "-"
             + Integer.toString(mLastUpdate.getSeconds()));
     FileOutputStream out = new FileOutputStream(settingsFile);
     // TODO : There is a usage of ini save method that deprecated.
     configFile.save(out, "properties updated");
   } catch (Exception e) {
     System.out.println("Write Exception:" + e.getMessage());
     return false;
   }
   return true;
 }