List of usage examples for java.util Calendar equals
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override public boolean equals(Object obj)
Calendar
to the specified Object
. From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKb.CFGenKbHPKey.java
public boolean equals(Object obj) { if (obj == null) { return (false); } else if (obj instanceof CFGenKbHPKey) { CFGenKbHPKey rhs = (CFGenKbHPKey) obj; {//from w w w . j av a 2 s. c o m long lhsClusterId = getAuditClusterId(); long rhsClusterId = rhs.getAuditClusterId(); if (lhsClusterId != rhsClusterId) { return (false); } } { Calendar lhsAuditStamp = getAuditStamp(); Calendar rhsAuditStamp = rhs.getAuditStamp(); if (lhsAuditStamp != null) { if (rhsAuditStamp != null) { if (!lhsAuditStamp.equals(rhsAuditStamp)) { return (false); } } else { return (false); } } else { return (false); } } { short lhsActionId = getAuditActionId(); short rhsActionId = rhs.getAuditActionId(); if (lhsActionId != rhsActionId) { return (false); } } { int lhsRevision = getRequiredRevision(); int rhsRevision = rhs.getRequiredRevision(); if (lhsRevision != rhsRevision) { return (false); } } { UUID lhsAuditSessionId = getAuditSessionId(); UUID rhsAuditSessionId = rhs.getAuditSessionId(); if (lhsAuditSessionId != null) { if (rhsAuditSessionId != null) { if (!lhsAuditSessionId.equals(rhsAuditSessionId)) { return (false); } } else { return (false); } } else { return (false); } } return (true); } else { return (false); } }
From source file:com.linuxbox.enkive.imap.mongo.MongoImapAccountCreator.java
public void createImapAccount(String username) throws MessageSearchException { HashMap<String, String> mailboxTable = new HashMap<String, String>(); Date earliestMessageDate = searchService.getEarliestMessageDate(username); Date latestMessageDate = searchService.getLatestMessageDate(username); Calendar latestMessageCalendar = Calendar.getInstance(); latestMessageCalendar.setTime(latestMessageDate); DateUtils.round(latestMessageCalendar, Calendar.DATE); Calendar today = Calendar.getInstance(); DateUtils.round(today, Calendar.DATE); if (latestMessageCalendar.equals(today)) { latestMessageCalendar.add(Calendar.DATE, -1); latestMessageDate = latestMessageCalendar.getTime(); }/*from w w w.j a va 2 s . com*/ // Setup Trash and Inbox BasicDBObject inboxObject = new BasicDBObject(); String inboxPath = "INBOX"; inboxObject.put(MongoEnkiveImapConstants.MESSAGEIDS, new HashMap<String, String>()); imapCollection.insert(inboxObject); ObjectId inboxId = (ObjectId) inboxObject.get("_id"); mailboxTable.put(inboxPath, inboxId.toString()); BasicDBObject trashObject = new BasicDBObject(); String trashPath = "Trash"; trashObject.put(MongoEnkiveImapConstants.MESSAGEIDS, new HashMap<String, String>()); imapCollection.insert(trashObject); ObjectId trashId = (ObjectId) inboxObject.get("_id"); mailboxTable.put(trashPath, trashId.toString()); BasicDBObject rootMailboxObject = new BasicDBObject(); imapCollection.insert(rootMailboxObject); ObjectId id = (ObjectId) rootMailboxObject.get("_id"); BasicDBObject userMailboxesObject = new BasicDBObject(); userMailboxesObject.put(MongoEnkiveImapConstants.USER, username); mailboxTable.put(MongoEnkiveImapConstants.ARCHIVEDMESSAGESFOLDERNAME, id.toString()); userMailboxesObject.put(MongoEnkiveImapConstants.MAILBOXES, mailboxTable); imapCollection.insert(userMailboxesObject); addImapMessages(username, earliestMessageDate, latestMessageDate); }
From source file:net.frontlinesms.plugins.reminders.RemindersThinletTabController.java
/** * Send a Reminder//from w w w.java 2s . c o m */ public void sendReminder(Reminder reminder) { LOG.debug("sendReminder: " + reminder); LOG.debug("sendReminder: " + reminder); if (reminder != null) { if (reminder.getType() == Reminder.Type.EMAIL) { if (reminder.getEmailAccount() != null) { for (String contactName : reminder.getRecipientsArray()) { LOG.debug("Sending EMAIL"); Contact contact = this.contactDao.getContactByName(contactName); Email email = new Email(reminder.getEmailAccount(), contact.getEmailAddress(), reminder.getSubject(), reminder.getContent()); this.emailDao.saveEmail(email); this.emailManager.sendEmail(email); } this.ui.setStatus( InternationalisationUtils.getI18NString(RemindersConstants.EMAIL_REMINDER_SENT)); } else { this.ui.alert( InternationalisationUtils.getI18NString(RemindersConstants.MISSING_EMAIL_ACCOUNT)); } } else if (reminder.getType() == Reminder.Type.MESSAGE) { for (String contactName : reminder.getRecipientsArray()) { Contact contact = this.contactDao.getContactByName(contactName); if (contact != null) { LOG.debug("Sending MESSAGE"); this.frontlineController.sendTextMessage(contact.getPhoneNumber(), reminder.getContent()); } } this.ui.setStatus(InternationalisationUtils.getI18NString(RemindersConstants.SMS_REMINDER_SENT)); } Calendar now = Calendar.getInstance(); if (now.equals(reminder.getEndCalendar())) { LOG.debug("now == end: " + reminder); reminder.setStatus(Reminder.Status.SENT); } else if (now.after(reminder.getEndCalendar())) { LOG.debug("now > end: " + reminder); reminder.setStatus(Reminder.Status.SENT); } this.reminderDao.updateReminder(reminder); } this.pagerReminders.refresh(); }
From source file:com.gitstudy.rili.liarbry.WeekViewPager.java
/** * // w ww. jav a 2 s . c o m * * @param year * @param month * @param day */ void scrollToCalendar(int year, int month, int day, boolean smoothScroll) { isUsingScrollToCalendar = true; Calendar calendar = new Calendar(); calendar.setYear(year); calendar.setMonth(month); calendar.setDay(day); calendar.setCurrentDay(calendar.equals(mDelegate.getCurrentDay())); LunarCalendar.setupLunarCalendar(calendar); mDelegate.mIndexCalendar = calendar; mDelegate.mSelectedCalendar = calendar; mDelegate.updateSelectCalendarScheme(); updateSelected(calendar, smoothScroll); if (mDelegate.mInnerListener != null) { mDelegate.mInnerListener.onWeekDateSelected(calendar, false); } if (mDelegate.mCalendarSelectListener != null) { mDelegate.mCalendarSelectListener.onCalendarSelect(calendar, false); } int i = CalendarUtil.getWeekFromDayInMonth(calendar, mDelegate.getWeekStart()); mParentLayout.updateSelectWeek(i); }
From source file:pula.sys.daos.impl.CourseClientDaoImpl.java
private boolean diff(Calendar expiredTime, Calendar expiredTime2) { if (expiredTime == expiredTime2) { return false; }/*from w w w . j a v a2s .com*/ if (expiredTime == null && expiredTime2 != null) { return true; } if (expiredTime != null && expiredTime2 == null) { return true; } if (expiredTime.equals(expiredTime2)) { return false; } return true; }
From source file:com.baidu.rigel.biplatform.ac.util.TimeRangeDetail.java
/** * ???/*w ww .ja v a 2s . c o m*/ * @return */ public String[] getDays() { if (StringUtils.isBlank(this.start)) { throw new IllegalArgumentException("start can not be null for timerange"); } if (StringUtils.isBlank(this.end)) { throw new IllegalArgumentException("end can not be null for timerange"); } Calendar startCalen = Calendar.getInstance(); Calendar endCalen = Calendar.getInstance(); try { startCalen.setTime(sdf.parse(start)); endCalen.setTime(sdf.parse(end)); } catch (ParseException e) { e.printStackTrace(); } List<String> days = Lists.newArrayList(); do { days.add(sdf.format(startCalen.getTime())); startCalen.add(Calendar.DAY_OF_MONTH, 1); } while (endCalen.equals(startCalen) || endCalen.after(startCalen)); return days.toArray(new String[0]); }
From source file:nl.strohalm.cyclos.services.accounts.guarantees.PaymentObligationServiceImpl.java
public boolean canChangeStatus(final PaymentObligation paymentObligation, final Status newStatus) { boolean isBuyer; boolean isSeller; switch (newStatus) { case PUBLISHED: final Calendar today = DateHelper.truncate(Calendar.getInstance()); final Calendar maxPublishDate = paymentObligation.getMaxPublishDate(); isBuyer = guaranteeService.isBuyer() && paymentObligation.getBuyer().equals(LoggedUser.accountOwner()); final boolean validDates = maxPublishDate.equals(today) || maxPublishDate.after(today); return isBuyer && validDates && isInSomeStatus(paymentObligation, Status.REGISTERED); case REGISTERED: // conceal isBuyer = guaranteeService.isBuyer() && paymentObligation.getBuyer().equals(LoggedUser.accountOwner()); return isBuyer && isInSomeStatus(paymentObligation, Status.PUBLISHED); case ACCEPTED: case REJECTED: isSeller = guaranteeService.isSeller() && paymentObligation.getSeller().equals(LoggedUser.accountOwner()); return isSeller && isInSomeStatus(paymentObligation, Status.PUBLISHED); default://from w ww .ja v a 2 s . c o m throw new PaymentObligationStatusChangeException(newStatus, "Can't change payment obligation's status, unsupported target status: " + newStatus); } }
From source file:com.cloudera.sqoop.manager.OracleManagerTest.java
/** * Compare two lines. Normalize the dates we receive based on the expected * time zone./*from w w w.java2 s .com*/ * @param expectedLine expected line * @param receivedLine received line * @throws IOException exception during lines comparison */ private void compareRecords(String expectedLine, String receivedLine) throws IOException { // handle null case if (expectedLine == null || receivedLine == null) { return; } // check if lines are equal if (expectedLine.equals(receivedLine)) { return; } // check if size is the same String[] expectedValues = expectedLine.split(","); String[] receivedValues = receivedLine.split(","); if (expectedValues.length != 7 || receivedValues.length != 7) { LOG.error("Number of expected fields did not match " + "number of received fields"); throw new IOException("Number of expected fields did not match " + "number of received fields"); } // check first 5 values boolean mismatch = false; for (int i = 0; !mismatch && i < 5; i++) { mismatch = !expectedValues[i].equals(receivedValues[i]); } if (mismatch) { throw new IOException("Expected:<" + expectedLine + "> but was:<" + receivedLine + ">"); } Date expectedDate = null; Date receivedDate = null; DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); int offset = TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 3600000; for (int i = 5; i < 7; i++) { // parse expected timestamp. try { expectedDate = df.parse(expectedValues[i]); } catch (ParseException ex) { LOG.error("Could not parse expected timestamp: " + expectedValues[i]); throw new IOException("Could not parse expected timestamp: " + expectedValues[i]); } // parse received timestamp try { receivedDate = df.parse(receivedValues[i]); } catch (ParseException ex) { LOG.error("Could not parse received timestamp: " + receivedValues[i]); throw new IOException("Could not parse received timestamp: " + receivedValues[i]); } // compare two timestamps considering timezone offset Calendar expectedCal = Calendar.getInstance(); expectedCal.setTime(expectedDate); expectedCal.add(Calendar.HOUR, offset); Calendar receivedCal = Calendar.getInstance(); receivedCal.setTime(receivedDate); if (!expectedCal.equals(receivedCal)) { throw new IOException("Expected:<" + expectedLine + "> but was:<" + receivedLine + ">, while timezone offset is: " + offset); } } }
From source file:com.vaquerosisd.projectmanager.NewProject.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_new_project); getActionBar().setDisplayHomeAsUpEnabled(true); //Initialize database operation object db = new ProjectOperations(this); db.open();//from w ww .j a v a 2 s .c o m //Initialize file operations instance fO = new FileOperations(this); //UI handlers references final EditText projectNameEditText = (EditText) findViewById(R.id.newProject_ProjectName); final EditText startDateEditText = (EditText) findViewById(R.id.newProject_StartDate); final EditText dueDateEditText = (EditText) findViewById(R.id.newProject_DueDate); statusSpinner = (Spinner) findViewById(R.id.newProject_StatusSpinner); final Button addProjectButton = (Button) findViewById(R.id.addProject); //Set spinner String statusItemsString = "New\nIn progress\nPrinting\nOn hold\nCancelled\nReviewing\nDelegated\nCompleted\n"; fO.createStringFile(statusFileName, statusItemsString); setStatusSpinner(); int statusPosition = statusSpinnerAdapter.getPosition("New"); statusSpinner.setSelection(statusPosition, true); //Check if custom option is selected to open a dialog to provide a custom status statusSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if ("Custom...".equals((String) statusSpinnerAdapter.getItem(position))) { DialogFragment customStatusDialog = new CustomStatus(); customStatusDialog.show(getFragmentManager(), "Custom Status Dialog"); } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); //StartDate click listener startDateEditText.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { showDatePickerDialog(arg0, STARTDATE_DIALOG_TAG, startDateEditText, startDateStrings); } }); //DueDate click listener dueDateEditText.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { showDatePickerDialog(arg0, DUEDATE_DIALOG_TAG, dueDateEditText, dueDateStrings); } }); //Add project to database addProjectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //Get EditText info String projectNameString = projectNameEditText.getText().toString(); String projectStatusString = statusSpinner.getSelectedItem().toString(); String projectStartDateString = startDateEditText.getText().toString(); String projectDueDateString = dueDateEditText.getText().toString(); //Add project to database if all input elements are filled boolean dueDateBeforeStartDate = true; Calendar startDateCalendar = Calendar.getInstance(); startDateCalendar.set(startDateStrings[0], startDateStrings[1], startDateStrings[2]); Calendar dueDateCalendar = Calendar.getInstance(); dueDateCalendar.set(dueDateStrings[0], dueDateStrings[1], dueDateStrings[2]); if (startDateCalendar.before(dueDateCalendar) || startDateCalendar.equals(dueDateCalendar)) dueDateBeforeStartDate = false; if (dueDateBeforeStartDate) { Toast.makeText(getApplicationContext(), R.string.dueDateError, Toast.LENGTH_LONG).show(); return; } else if (!projectNameString.equals("") && !projectStartDateString.equals("") && !projectDueDateString.equals("")) { File contentDir = new File("/storage/sdcard0/ProjectManager/" + projectNameString); contentDir.mkdirs(); db.addProject(projectNameString, projectStatusString, startDateStrings, dueDateStrings, contentDir.getAbsolutePath()); Toast.makeText(getApplicationContext(), R.string.projectAdded, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), R.string.incomplete, Toast.LENGTH_LONG).show(); return; } //Inform of successful adding Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); } }); }
From source file:com.vaquerosisd.projectmanager.NewTask.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_new_task); //Set navigation up getActionBar().setDisplayHomeAsUpEnabled(true); //Initialize database db = new ProjectOperations(this); db.open();// ww w . jav a 2 s . c o m //Initialize file operations instance fO = new FileOperations(this); //Get intent from Projects.class Bundle data = getIntent().getExtras(); projectId = data.getInt("ProjectID"); projectName = data.getString("ProjectName"); //Get UI handler references final EditText taskNameEditText = (EditText) findViewById(R.id.newTask_TaskName); final Spinner statusSpinner = (Spinner) findViewById(R.id.newTask_StatusSpinner); final Spinner prioritySpinner = (Spinner) findViewById(R.id.newTask_Priority); final EditText percentageDoneEditText = (EditText) findViewById(R.id.newTask_PercentageDone); final SeekBar percentageDoneSeekBar = (SeekBar) findViewById(R.id.newTask_PercentageDoneSeekBar); final EditText startDateEditText = (EditText) findViewById(R.id.newTask_StartDate); final EditText dueDateEditText = (EditText) findViewById(R.id.newTask_DueDate); final EditText descriptionEditText = (EditText) findViewById(R.id.newTask_Description); final Button addTaskButton = (Button) findViewById(R.id.newTask_AddTask); final int[] startDateStrings = { 0, 0, 0 }; final int[] dueDateStrings = { 0, 0, 0 }; //Set files they doesn't exist String statusItemsString = "New\nIn progress\nPrinting\nOn hold\nCancelled\nReviewing\nDelegated\nCompleted\n"; fO.createStringFile(statusFileName, statusItemsString); String priorityItemsString = "High\nMedium\nLow\n"; fO.createStringFile(priorityFileName, priorityItemsString); //Create and set content for the status and priority spinners setSpinner(statusFileName, statusSpinnerAdapter, statusSpinner, true); setSpinner(priorityFileName, prioritySpinnerAdapter, prioritySpinner, false); percentageDoneEditText.setText("0%"); // int statusPosition = statusSpinnerAdapter.getPosition("New"); // statusSpinner.setSelection(statusPosition, true); addTaskButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { //Get values for the add task String projectDir = db.getProjectContentPath(projectId); String taskName = taskNameEditText.getText().toString(); String status = statusSpinner.getSelectedItem().toString(); String priority = prioritySpinner.getSelectedItem().toString(); String percentage = percentageDoneEditText.getText().toString(); int percentageDone = Integer.parseInt(percentage.substring(0, percentage.length() - 1)); String startDate = startDateEditText.getText().toString(); String dueDate = dueDateEditText.getText().toString(); String photoPath = ""; String description = descriptionEditText.getText().toString(); String contentPath = projectDir + "/" + taskName; Log.i("DEBUG", contentPath); File taskContentPath = new File(contentPath); taskContentPath.mkdir(); boolean dueDateBeforeStartDate = true; Calendar startDateCalendar = Calendar.getInstance(); startDateCalendar.set(startDateStrings[0], startDateStrings[1], startDateStrings[2]); Calendar dueDateCalendar = Calendar.getInstance(); dueDateCalendar.set(dueDateStrings[0], dueDateStrings[1], dueDateStrings[2]); if (startDateCalendar.before(dueDateCalendar) || startDateCalendar.equals(dueDateCalendar)) dueDateBeforeStartDate = false; if (dueDateBeforeStartDate) { Toast.makeText(getApplicationContext(), R.string.dueDateError, Toast.LENGTH_SHORT).show(); return; } else if (!taskName.equals("") && !startDate.equals("") && !dueDate.equals("")) { db.addTask(projectId, taskName, status, priority, percentageDone, startDateStrings, dueDateStrings, photoPath, description, contentPath); Toast.makeText(getApplicationContext(), R.string.taskAdded, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), R.string.incomplete, Toast.LENGTH_SHORT).show(); return; } //Inform of successful adding Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); } }); //SeekBar listener percentageDoneSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { percentageDoneEditText.setText(String.valueOf(progress) + "%"); } }); //StartDate click listener startDateEditText.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { showDatePickerDialog(arg0, STARTDATE_DIALOG_TAG, startDateEditText, startDateStrings); } }); //StartDate click listener dueDateEditText.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { showDatePickerDialog(arg0, DUEDATE_DIALOG_TAG, dueDateEditText, dueDateStrings); } }); }