예제 #1
0
  public static boolean checkDate(String date1, String date2) {

    Date date11 = DateUtil.str2Date(date1, "yyyy-MM-dd HH:mm:ss"); // 起始时间

    Date date22 = DateUtil.str2Date(date2, "yyyy-MM-dd HH:mm:ss"); // 终止时间

    Calendar scalendar = Calendar.getInstance();
    scalendar.setTime(date11); // 起始时间

    Calendar ecalendar = Calendar.getInstance();
    ecalendar.setTime(date22); // 终止时间

    Calendar calendarnow = Calendar.getInstance();

    System.out.println(date11.toString());
    System.out.println(date22.toString());
    System.out.println(scalendar.toString());
    System.out.println(ecalendar.toString());
    System.out.println(calendarnow.toString());

    if (calendarnow.after(scalendar) && calendarnow.before(ecalendar)) {
      return true;
    } else {
      return false;
    }
  }
 @TestTargetNew(
     level = TestLevel.COMPLETE,
     notes = "",
     method = "toString",
     args = {})
 public void test_toString() {
   Calendar cal1 = Calendar.getInstance();
   Calendar cal2 = Calendar.getInstance();
   cal1.setTimeZone(TimeZone.getTimeZone("GMT-6"));
   cal2.setTimeZone(TimeZone.getTimeZone("GMT-8"));
   cal1.set(Calendar.MILLISECOND, 0);
   cal2.set(Calendar.MILLISECOND, 0);
   assertFalse(cal1.toString().equals(cal2.toString()));
   cal1.setTimeZone(TimeZone.getTimeZone("GMT-8"));
   assertTrue(cal1.toString().equals(cal2.toString()));
 }
예제 #3
0
  public void doWork(Context context) {
    AIDSDBHelper aidsDBHelper = AIDSDBHelper.getInstance(context);

    Calendar calendar = Calendar.getInstance();
    long currentTimeMillis = calendar.getTimeInMillis();
    Calendar prevCalendar = Calendar.getInstance();
    prevCalendar.add(Calendar.SECOND, -1 * RunEvery);
    long prevTimeMillis = prevCalendar.getTimeInMillis();

    aidsDBHelper.insertLog(
        String.format("Running GAnalyzer for %s-%s", calendar.toString(), prevCalendar.toString()));
    String gModelName = "_global" + calendar.get(Calendar.HOUR_OF_DAY);

    // get global model
    IEModel gModel = aidsDBHelper.getIEModel(gModelName);

    if (gModel == null) {
      // first invocation
      gModel = new IEModel();
      gModel.ProcessName = gModelName;
      gModel.FromTimeStamp = prevTimeMillis;
      gModel.ToTimeStamp = currentTimeMillis;
      gModel.Age = 1;

      aidsDBHelper.insertIEModel(gModel);
    }

    // get IEModels of processes for past hour
    HashMap<String, IEModel> processMap =
        getIEModelsForProcesses(aidsDBHelper, prevTimeMillis, currentTimeMillis);

    for (String pName : processMap.keySet()) {
      IEModel newModel = processMap.get(pName);

      // update the model with current generation
      gModel.ToTimeStamp = currentTimeMillis;
      gModel.CPULow += newModel.CPULow;
      gModel.CPUMid += newModel.CPUMid;
      gModel.CPUHigh += newModel.CPUHigh;
      gModel.CPUCounter += newModel.CPUCounter;
      gModel.Age = gModel.Age + 1; // and increment the age

      aidsDBHelper.updateIEModel(gModel);
    }
  }
  @TestTargetNew(
      level = TestLevel.COMPLETE,
      notes = "",
      method = "computeFields",
      args = {})
  public void test_computeFields() {
    Calendar cal1 = Calendar.getInstance(TimeZone.getTimeZone("GMT+2"), defaultLocale);
    Calendar cal2 = Calendar.getInstance(TimeZone.getTimeZone("GMT+2"), defaultLocale);

    cal1.setTimeInMillis(1222185600225L);
    cal2.set(2008, Calendar.SEPTEMBER, 23, 18, 0, 0);
    assertFalse(cal1.toString().equals(cal2.toString()));
    cal1.get(Calendar.YEAR);
    cal2.getTimeInMillis();
    cal1.set(Calendar.MILLISECOND, 0);
    cal2.set(Calendar.MILLISECOND, 0);
    // tests fails in this line.
    assertTrue(cal1.toString().equals(cal2.toString()));
  }
예제 #5
0
  public void onDateSet(DatePicker view, int year, int month, int day) {
    // Do something with the date chosen by the user
    Calendar c = Calendar.getInstance();
    c.set(Calendar.YEAR, year);
    c.set(Calendar.MONTH, month);
    c.set(Calendar.DAY_OF_MONTH, day);
    Log.d("cal", c.toString());

    TextView dateText = (TextView) getActivity().findViewById(R.id.dateEditText);
    dateText.setText(new SimpleDateFormat("EEE, MMM d").format(c.getTime()));
  }
예제 #6
0
파일: Event.java 프로젝트: shimy249/SCAN
  public Event(
      String n, String s, Calendar start, Calendar end, String $calendarName, int $colorNumber) {
    name = n;
    summary = s;
    startDate = start;
    endDate = end;
    Log.v("tag", end.toString());

    calendarName = $calendarName;
    colorNumber = $colorNumber;
  }
  /**
   * Issues a phone account to a given person.
   *
   * @param accountHolderName the name of the account holder
   * @param accountHolderDob the date of birth of the account holder
   * @param accountType the type of account required
   * @return The phone account created for the given person
   */
  public Phone issuePhone(String accountHolderName, Calendar accountHolderDob, String accountType) {
    if (accountHolderName == null || accountType == null || accountHolderDob == null) {
      LOG.warning(
          "Bad parameter sent. name:"
              + accountHolderName
              + " account type: "
              + accountType
              + " DOB: "
              + accountHolderDob.toString());
      throw new IllegalArgumentException("All parameters must be none null");
    }

    if (accountHolderDob.after(Calendar.getInstance())) {
      LOG.warning("Date of birth passed was in the future");
      throw new IllegalArgumentException("Date of birth cannot not be in the future");
    }

    PhoneAccount pa;
    if (accountType.equals(PhoneAccountFactory.PAY_AS_YOU_GO)) {

      Person accountHolder =
          new Person(accountHolderName, new Date(accountHolderDob.getTimeInMillis()));
      pa = PhoneAccountFactory.getInstance(getNewPhoneNumber(), accountHolder, accountType);

    } else if (accountType == PhoneAccountFactory.UNLIMITED) {

      Calendar ageLimit = Calendar.getInstance();
      ageLimit.set(Calendar.YEAR, (ageLimit.get(Calendar.YEAR) - 18));

      if (ageLimit.before(accountHolderDob)) {
        LOG.warning("Customer is not old enough for this account: " + accountHolderName);
        return null;
      } else {
        Person accountHolder =
            new Person(accountHolderName, new Date(accountHolderDob.getTimeInMillis()));
        pa = PhoneAccountFactory.getInstance(getNewPhoneNumber(), accountHolder, accountType);
      }

    } else {
      throw new IllegalArgumentException("Invalid Phone Account type");
    }
    LOG.info("New Account Created: " + pa.getNumber().toString());
    return new Phone(pa);
  }
  public void submitTransaction(View view) {
    Calendar currentDate = Calendar.getInstance();
    TransactionService TransactionService = new TransactionService();
    TransactionService.getTransactions();
    EditText item = (EditText) findViewById(R.id.Item);
    EditText amount = (EditText) findViewById(R.id.Amount);
    EditText employee = (EditText) findViewById(R.id.Employee);
    String product = item.getText().toString();
    String amountPurchased = amount.getText().toString();
    String employeeOnDuty = employee.getText().toString();

    Transaction newTransaction = new Transaction();
    newTransaction.setId(UUID.randomUUID());
    newTransaction.setItem(product);
    newTransaction.setAmount(amountPurchased);
    newTransaction.setEmployee(employeeOnDuty);
    newTransaction.setDate(currentDate.toString());
    TransactionService.setTransaction(newTransaction);

    Intent manageTransactionintent = new Intent(this, manageTrnasactions.class);
    startActivity(manageTransactionintent);
  }
예제 #9
0
 public String toStringGmtTime() {
   return date.toString();
 }
예제 #10
0
 public String toStringGmtShort() {
   return date.toString();
 }
예제 #11
0
 public String toStringGmtFull() {
   return date.toString();
 }
예제 #12
0
 public String getDisplay() {
   return date.toString();
 }
예제 #13
0
 public String toStringSql() {
   return date.toString();
 }
예제 #14
0
  public java.lang.String toString() {

    return localDateTime.toString();
  }
예제 #15
0
 public String getStringInitialDate() {
   return initialDate.toString();
 }
예제 #16
0
 public String toStringLocalDate() {
   return date.toString();
 }
예제 #17
0
 @Override
 public String toString() {
   return String.format("%s;%s;%s", mTime.toString(), mTitle, mUrl);
 }
예제 #18
0
 public String toStringLocalFull() {
   return date.toString();
 }
예제 #19
0
 public String toStringLocalShort() {
   return date.toString();
 }
예제 #20
0
 public String toStringLocalTimeZ() {
   return date.toString();
 }
예제 #21
0
 public String toStringRFC822Local() {
   return date.toString();
 }
예제 #22
0
 /** Returns a string representation of this timing specifier. */
 public String toString() {
   return "wallclock(" + time.toString() + ")";
 }
예제 #23
0
 /**
  * Gets the displayed text for the currently selected item (i.e. the text representation of the
  * date)
  *
  * @return the displayed text as a string
  */
 public String getText() {
   return mSelectedDate.toString();
 }