List of usage examples for java.util Date getDate
@Deprecated public int getDate()
From source file:org.kuali.kra.service.impl.PersonEditableServiceImpl.java
public void populateContactFieldsFromPersonId(PersonEditableInterface protocolPerson) { DateFormat dateFormat = new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT_PATTERN); KcPerson person = this.kcPersonService.getKcPersonByPersonId(protocolPerson.getPersonId()); protocolPerson.setSocialSecurityNumber(person.getSocialSecurityNumber()); protocolPerson.setLastName(person.getLastName()); protocolPerson.setFirstName(person.getFirstName()); protocolPerson.setMiddleName(person.getMiddleName()); protocolPerson.setFullName(person.getFullName()); protocolPerson.setPriorName(person.getPriorName()); protocolPerson.setUserName(person.getUserName()); protocolPerson.setEmailAddress(person.getEmailAddress()); //prop_person.setDateOfBirth(person.getDateOfBirth()); try {//from w ww . ja v a 2 s.co m java.util.Date dobUtil = dateFormat.parse(person.getDateOfBirth()); protocolPerson .setDateOfBirth(new java.sql.Date(dobUtil.getYear(), dobUtil.getMonth(), dobUtil.getDate())); } catch (Exception e) { //invalid date protocolPerson.setDateOfBirth(null); } protocolPerson.setAge(person.getAge()); protocolPerson.setAgeByFiscalYear(person.getAgeByFiscalYear()); protocolPerson.setGender(person.getGender()); protocolPerson.setRace(person.getRace()); protocolPerson.setEducationLevel(person.getEducationLevel()); protocolPerson.setDegree(person.getDegree()); protocolPerson.setMajor(person.getMajor()); protocolPerson.setHandicappedFlag(person.getHandicappedFlag()); protocolPerson.setHandicapType(person.getHandicapType()); protocolPerson.setVeteranFlag(person.getVeteranFlag()); protocolPerson.setVeteranType(person.getVeteranType()); protocolPerson.setVisaCode(person.getVisaCode()); protocolPerson.setVisaType(person.getVisaType()); //prop_person.setVisaRenewalDate(person.getVisaRenewalDate()); try { java.util.Date visaUtil = dateFormat.parse(person.getVisaRenewalDate()); protocolPerson.setVisaRenewalDate( new java.sql.Date(visaUtil.getYear(), visaUtil.getMonth(), visaUtil.getDate())); } catch (Exception e) { //invalid date protocolPerson.setVisaRenewalDate(null); } protocolPerson.setHasVisa(person.getHasVisa()); protocolPerson.setOfficeLocation(person.getOfficeLocation()); protocolPerson.setOfficePhone(person.getOfficePhone()); protocolPerson.setSecondaryOfficeLocation(person.getSecondaryOfficeLocation()); protocolPerson.setSecondaryOfficePhone(person.getSecondaryOfficePhone()); protocolPerson.setSchool(person.getSchool()); protocolPerson.setYearGraduated(person.getYearGraduated()); protocolPerson.setDirectoryDepartment(person.getDirectoryDepartment()); protocolPerson.setSaluation(person.getSaluation()); protocolPerson.setCountryOfCitizenship(person.getCountryOfCitizenship()); protocolPerson.setPrimaryTitle(person.getPrimaryTitle()); protocolPerson.setDirectoryTitle(person.getDirectoryTitle()); protocolPerson.setHomeUnit(person.getOrganizationIdentifier()); protocolPerson.setFacultyFlag(person.getFacultyFlag()); protocolPerson.setGraduateStudentStaffFlag(person.getGraduateStudentStaffFlag()); protocolPerson.setResearchStaffFlag(person.getResearchStaffFlag()); protocolPerson.setServiceStaffFlag(person.getServiceStaffFlag()); protocolPerson.setSupportStaffFlag(person.getSupportStaffFlag()); protocolPerson.setOtherAcademicGroupFlag(person.getOtherAcademicGroupFlag()); protocolPerson.setMedicalStaffFlag(person.getMedicalStaffFlag()); protocolPerson.setVacationAccrualFlag(person.getVacationAccrualFlag()); protocolPerson.setOnSabbaticalFlag(person.getOnSabbaticalFlag()); protocolPerson.setIdProvided(person.getIdProvided()); protocolPerson.setIdVerified(person.getIdVerified()); protocolPerson.setAddressLine1(person.getAddressLine1()); protocolPerson.setAddressLine2(person.getAddressLine2()); protocolPerson.setAddressLine3(person.getAddressLine3()); protocolPerson.setCity(person.getCity()); protocolPerson.setCounty(person.getCounty()); protocolPerson.setState(person.getState()); protocolPerson.setPostalCode(person.getPostalCode()); protocolPerson.setCountryCode(person.getCountryCode()); protocolPerson.setFaxNumber(person.getFaxNumber()); protocolPerson.setPagerNumber(person.getPagerNumber()); protocolPerson.setMobilePhoneNumber(person.getMobilePhoneNumber()); protocolPerson.setEraCommonsUserName(person.getEraCommonsUserName()); }
From source file:eu.inmite.apps.smsjizdenka.util.SmsParser.java
private Date parseDate(String text, String datePattern, SimpleDateFormat sdf, SimpleDateFormat sdfTime, Ticket ticket) {/*from ww w . j av a2 s. c o m*/ Matcher m = Pattern.compile(datePattern).matcher(text); if (m.find()) { String d = m.group(1); if (!isEmpty(d)) { d = d.replaceAll(";", ""); for (int i = 0; i < 2; i++) { final Date date; try { if (i == 0) { date = sdf.parse(d); // full date/time } else if (i == 1 && sdfTime != null) { date = sdfTime.parse(d); // only time } else { break; } } catch (Exception e) { continue; } if (i == 1 && ticket != null && ticket.validFrom != null) { final Date prevDate = ticket.validFrom; date.setYear(prevDate.getYear()); date.setMonth(prevDate.getMonth()); date.setDate(prevDate.getDate()); } return date; } } } throw new RuntimeException("Cannot parse date from the message " + text); }
From source file:de.grobox.liberario.TripDetailActivity.java
@SuppressWarnings("deprecation") private void addHeader(Trip trip) { Date d = trip.getFirstDepartureTime(); ((TextView) findViewById(R.id.tripDetailsDurationView)) .setText(DateUtils.getDuration(trip.getFirstDepartureTime(), trip.getLastArrivalTime())); ((TextView) findViewById(R.id.tripDetailsDateView)) .setText(DateUtils.formatDate(this, d.getYear() + 1900, d.getMonth(), d.getDate())); }
From source file:org.kuali.coeus.common.impl.editable.PersonEditableServiceImpl.java
public void populateContactFieldsFromPersonId(PersonEditable protocolPerson) { DateFormat dateFormat = new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT_PATTERN); KcPerson person = this.kcPersonService.getKcPersonByPersonId(protocolPerson.getPersonId()); protocolPerson.setSocialSecurityNumber(person.getSocialSecurityNumber()); protocolPerson.setLastName(person.getLastName()); protocolPerson.setFirstName(person.getFirstName()); protocolPerson.setMiddleName(person.getMiddleName()); protocolPerson.setFullName(person.getFullName()); protocolPerson.setPriorName(person.getPriorName()); protocolPerson.setUserName(person.getUserName()); protocolPerson.setEmailAddress(person.getEmailAddress()); try {//from ww w . j ava2s . c o m java.util.Date dobUtil = dateFormat.parse(person.getDateOfBirth()); protocolPerson .setDateOfBirth(new java.sql.Date(dobUtil.getYear(), dobUtil.getMonth(), dobUtil.getDate())); } catch (Exception e) { //invalid date protocolPerson.setDateOfBirth(null); } protocolPerson.setAge(person.getAge()); protocolPerson.setAgeByFiscalYear(person.getAgeByFiscalYear()); protocolPerson.setGender(person.getGender()); protocolPerson.setRace(person.getRace()); protocolPerson.setEducationLevel(person.getEducationLevel()); protocolPerson.setDegree(person.getDegree()); protocolPerson.setMajor(person.getMajor()); protocolPerson.setHandicappedFlag(person.getHandicappedFlag()); protocolPerson.setHandicapType(person.getHandicapType()); protocolPerson.setVeteranFlag(person.getVeteranFlag()); protocolPerson.setVeteranType(person.getVeteranType()); protocolPerson.setVisaCode(person.getVisaCode()); protocolPerson.setVisaType(person.getVisaType()); try { java.util.Date visaUtil = dateFormat.parse(person.getVisaRenewalDate()); protocolPerson.setVisaRenewalDate( new java.sql.Date(visaUtil.getYear(), visaUtil.getMonth(), visaUtil.getDate())); } catch (Exception e) { //invalid date protocolPerson.setVisaRenewalDate(null); } protocolPerson.setHasVisa(person.getHasVisa()); protocolPerson.setOfficeLocation(person.getOfficeLocation()); protocolPerson.setOfficePhone(person.getOfficePhone()); protocolPerson.setSecondaryOfficeLocation(person.getSecondaryOfficeLocation()); protocolPerson.setSecondaryOfficePhone(person.getSecondaryOfficePhone()); protocolPerson.setSchool(person.getSchool()); protocolPerson.setYearGraduated(person.getYearGraduated()); protocolPerson.setDirectoryDepartment(person.getDirectoryDepartment()); protocolPerson.setSaluation(person.getSaluation()); protocolPerson.setCountryOfCitizenship(person.getCountryOfCitizenship()); protocolPerson.setPrimaryTitle(person.getPrimaryTitle()); protocolPerson.setDirectoryTitle(person.getDirectoryTitle()); protocolPerson.setHomeUnit(person.getOrganizationIdentifier()); protocolPerson.setFacultyFlag(person.getFacultyFlag()); protocolPerson.setGraduateStudentStaffFlag(person.getGraduateStudentStaffFlag()); protocolPerson.setResearchStaffFlag(person.getResearchStaffFlag()); protocolPerson.setServiceStaffFlag(person.getServiceStaffFlag()); protocolPerson.setSupportStaffFlag(person.getSupportStaffFlag()); protocolPerson.setOtherAcademicGroupFlag(person.getOtherAcademicGroupFlag()); protocolPerson.setMedicalStaffFlag(person.getMedicalStaffFlag()); protocolPerson.setVacationAccrualFlag(person.getVacationAccrualFlag()); protocolPerson.setOnSabbaticalFlag(person.getOnSabbaticalFlag()); protocolPerson.setIdProvided(person.getIdProvided()); protocolPerson.setIdVerified(person.getIdVerified()); protocolPerson.setAddressLine1(person.getAddressLine1()); protocolPerson.setAddressLine2(person.getAddressLine2()); protocolPerson.setAddressLine3(person.getAddressLine3()); protocolPerson.setCity(person.getCity()); protocolPerson.setCounty(person.getCounty()); protocolPerson.setState(person.getState()); protocolPerson.setPostalCode(person.getPostalCode()); protocolPerson.setCountryCode(person.getCountryCode()); protocolPerson.setFaxNumber(person.getFaxNumber()); protocolPerson.setPagerNumber(person.getPagerNumber()); protocolPerson.setMobilePhoneNumber(person.getMobilePhoneNumber()); protocolPerson.setEraCommonsUserName(person.getEraCommonsUserName()); protocolPerson.setCitizenshipTypeCode(person.getCitizenshipTypeCode()); }
From source file:com.webpagebytes.wpbsample.SampleJob.java
public void execute(JobExecutionContext context) throws JobExecutionException { log.log(Level.INFO, "Sample quartz scheduler started"); // create the email subject value Date yesterday = DateUtility.addDays(DateUtility.getToday(), -1); String subject = String.format("Sample webpagebytes application report(%d/%d/%d)", 1900 + yesterday.getYear(), yesterday.getMonth() + 1, yesterday.getDate()); // various variables used during report generation ByteArrayOutputStream bos_emailBody = new ByteArrayOutputStream(4096); ByteArrayOutputStream bos_emailAttachmentFop = new ByteArrayOutputStream(4096); InputStream is_emailAttachmentFop = null; ByteArrayOutputStream bos_emailAttachmentPdf = new ByteArrayOutputStream(4096); ByteArrayInputStream bis_emailAttachmentPdf = null; try {//from ww w . j a va 2s . c o m // get the content provider instance WPBContentService contentService = WPBContentServiceFactory.getInstance(); WPBContentProvider contentProvider = contentService.getContentProvider(); // create the cmd model WPBModel model = contentService.createModel(); //get the report images for users, transactions, deposits and withdrawals // the images and stored in a map, the image content is base64 encoded Map<String, String> contentImages = new HashMap<String, String>(); NotificationUtility.fetchReportImages(contentProvider, model, contentImages); //populate the model with image values model.getCmsApplicationModel().put("users_img", contentImages.get(NotificationUtility.CONTENT_IMG_USERS)); model.getCmsApplicationModel().put("transactions_img", contentImages.get(NotificationUtility.CONTENT_IMG_TRANSACTIONS)); model.getCmsApplicationModel().put("deposits_img", contentImages.get(NotificationUtility.CONTENT_IMG_DEPOSITS)); model.getCmsApplicationModel().put("withdrawals_img", contentImages.get(NotificationUtility.CONTENT_IMG_WITHDRAWALS)); // get from the GLOBALS parameters the user who will receive the email notification String notificationEmailAddress = model.getCmsModel().get(WPBModel.GLOBALS_KEY) .get("NOTIFICATIONS_EMAIL_ADDRESS"); // get from the GLOBALS parameters the page guid with the email body template String notificationEmailPageGuid = model.getCmsModel().get(WPBModel.GLOBALS_KEY) .get("NOTIFICATIONS_EMAIL_PAGE_GUID"); // get from the GLOBALS parameters the page guid with the PDF report XSL-FO template String notificationEmailAttachmentGuid = model.getCmsModel().get(WPBModel.GLOBALS_KEY) .get("NOTIFICATIONS_EMAIL_PDF_GUID"); if (notificationEmailAddress == null || notificationEmailPageGuid == null || notificationEmailAttachmentGuid == null) { // if any of these is not set then do not sent the email log.log(Level.WARNING, "Sample scheduler not properly configured, will not send any email"); return; } // translate the email body template into the actual body content contentProvider.writePageContent(notificationEmailPageGuid, model, bos_emailBody); // translate the attachment XSL FO template into the actual XSL FO content contentProvider.writePageContent(notificationEmailAttachmentGuid, model, bos_emailAttachmentFop); // need to convert the attachment XSL FO OutputStream into InputStream is_emailAttachmentFop = new ByteArrayInputStream(bos_emailAttachmentFop.toByteArray()); SampleFopService fopService = SampleFopService.getInstance(); fopService.getContent(is_emailAttachmentFop, MimeConstants.MIME_PDF, bos_emailAttachmentPdf); //need to convert the attachment PDF OutputStream into InputStream bis_emailAttachmentPdf = new ByteArrayInputStream(bos_emailAttachmentPdf.toByteArray()); // now we have the email subject, email body, email attachment, we can sent it if (notificationEmailAddress.length() > 0) { EmailUtility emailUtility = EmailUtilityFactory.getInstance(); emailUtility.sendEmail(notificationEmailAddress, "no-reply@webpagebytes.com", subject, bos_emailBody.toString("UTF-8"), "report.pdf", bis_emailAttachmentPdf); } log.log(Level.INFO, "Sample quartz scheduler completed with success"); } catch (Exception e) { log.log(Level.SEVERE, "Exception on quartz scheduler", e); } finally { IOUtils.closeQuietly(bos_emailBody); IOUtils.closeQuietly(bos_emailAttachmentFop); IOUtils.closeQuietly(is_emailAttachmentFop); IOUtils.closeQuietly(bis_emailAttachmentPdf); IOUtils.closeQuietly(bos_emailAttachmentPdf); } }
From source file:org.openmrs.api.impl.ConditionServiceImplIT.java
@Test public void shouldEndConditionSetEndDateAsTodayIfNotSpecified() { Condition condition = conditionService.getConditionByUuid("2ss6880e-2c46-11e4-5844-a6c5e4d22fb7"); Date endDate = new Date(); Concept endReason = conceptService.getConceptByUuid("cured84f-1yz9-4da3-bb88-8122ce8868ss"); condition.setEndReason(endReason);// www .jav a 2 s .com Condition savedCondition = conditionService.save(condition); assertEquals(savedCondition.getEndDate().getDate(), endDate.getDate()); }
From source file:at.flack.MailMainActivity.java
public String getDate(Date date) { Date today = new Date(System.currentTimeMillis()); if (date.getDate() == today.getDate() && date.getMonth() == today.getMonth() && date.getYear() == today.getYear()) return new SimpleDateFormat("HH:mm", Locale.getDefault()).format(date); else//from w w w . j a v a 2s. co m return new SimpleDateFormat("dd. MMM", Locale.getDefault()).format(date); }
From source file:UserInterface.CustomerRole.CustomerOrderSchedulingJPanel.java
private void scheduleAppointmentBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scheduleAppointmentBtnActionPerformed // TODO add your handling code here: int hourOfDay = 0; boolean flag = true; DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date1 = new Date(); try {// w w w. j a va 2 s. c o m date1 = dateFormat.parse(dateFormat.format(date1)); hourOfDay = date1.getHours(); //System.out.println(hourOfDay); } catch (Exception e) { System.out.println("Parsing Error of date!!!"); flag = false; } if (seletedFlag == 0) { JOptionPane.showMessageDialog(this, "Selection of Enterprise(Retailer Type) Node is a manadate!!"); flag = false; return; } else if (selectedEnterpriseJLabel.getText().toString().equals("JTree")) { JOptionPane.showMessageDialog(this, "Selection of Enterprise(Retailer Type) Node is a manadate!!"); flag = false; return; } else { for (Network network : system.getNetworkList()) { if (network.getName().equals(selectedEnterpriseJLabel.getText().toString()) || selectedEnterpriseJLabel.getText().toString().equals("Networks")) { JOptionPane.showMessageDialog(this, "Selection of Enterprise(Retailer Type) Node is a manadate!!"); flag = false; return; } for (Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()) { if (enterprise.getName().equals(selectedEnterpriseJLabel.getText())) { if (enterprise.getEnterpriseType().getValue().equals("Retailer")) { Date date; try { date = scheduleDate.getDate(); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Select a date before scheduling!!!"); flag = false; return; } String time = timeCmbBox.getSelectedItem().toString(); if (time.equals("---")) { JOptionPane.showMessageDialog(this, "Select a time slot before scheduling!!!"); flag = false; return; } Date dt = new Date(); if (dt.getDate() == date.getDate()) { String time1 = timeCmbBox.getSelectedItem().toString(); time1 = StringUtils.substringBefore(time1, ":"); if (Integer.parseInt(time1) < hourOfDay) { JOptionPane.showMessageDialog(this, "Time Slot selection from past is not allowed!!!"); flag = false; return; } } WorkRequest request = new WorkRequest(); request.setMessage("Buy a Car"); request.setScheduleDate(date); request.setScheduleTime(time); request.setCustomer(userAccount.getCustomer()); request.setSender(userAccount); request.setStatus("Sent"); //Network network2 = new Network(); Organization org = null; for (Network network1 : system.getNetworkList()) { if (network1.getName().equals(selectNetworkName.getSelectedItem().toString())) { for (Enterprise enterprise1 : network1.getEnterpriseDirectory() .getEnterpriseList()) { if (enterprise1.getName() .equalsIgnoreCase(selectedEnterpriseJLabel.getText())) { for (Organization organization1 : enterprise1.getOrganizationDirectory() .getOrganizationList()) { if (organization1 instanceof SalesReceptionistOrganization) { org = organization1; //int gotOrganization = 1; break; } } } } } } if (org != null) { org.getWorkQueue().getWorkRequestList().add(request); userAccount.getWorkQueue().getWorkRequestList().add(request); } } else { JOptionPane.showMessageDialog(this, "Selection of Enterprise(Retailer Type) Node is a manadate!!"); flag = false; return; } } else { for (Organization organization : enterprise.getOrganizationDirectory() .getOrganizationList()) { if (organization.getName().equals(selectedEnterpriseJLabel.getText().toString())) { JOptionPane.showMessageDialog(this, "Selection of Enterprise(Retailer Type) Node is a manadate!!"); flag = false; return; } } } } } } if (flag) { JOptionPane.showMessageDialog(this, "Appointment is successfully scheduled !!!"); } }
From source file:org.yccheok.jstock.gui.news.StockNewsJFrame.java
private boolean isSameDay(Date date0, Date date1) { return date0.getDate() == date1.getDate() && date0.getMonth() == date1.getMonth() && date0.getYear() == date1.getYear(); }
From source file:org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController.java
/** * Binds Datebox "init date" to the corresponding attribute of a {@link ResourcesCostCategoryAssignment} * * @param dateBoxInitDate/*from ww w .j a v a 2s. c o m*/ * @param hourCost */ private void bindDateboxEndDate(final Datebox dateBoxEndDate, final ResourcesCostCategoryAssignment assignment) { Util.bind(dateBoxEndDate, new Util.Getter<Date>() { @Override public Date get() { LocalDate dateTime = assignment.getEndDate(); if (dateTime != null) { return new Date(dateTime.getYear() - 1900, dateTime.getMonthOfYear() - 1, dateTime.getDayOfMonth()); } return null; } }, new Util.Setter<Date>() { @Override public void set(Date value) { if (value != null) { assignment.setEndDate( new LocalDate(value.getYear() + 1900, value.getMonth() + 1, value.getDate())); } else { assignment.setEndDate(null); } } }); }