List of usage examples for java.util Date equals
public boolean equals(Object obj)
From source file:org.apache.ranger.plugin.conditionevaluator.RangerScriptExecutionContext.java
public boolean isAccessedAfter(String attributeName) { boolean ret = false; Date accessDate = getAccessTime(); Date expiryDate = getAsDate(getAttributeValue(attributeName)); if (expiryDate == null || accessDate.after(expiryDate) || accessDate.equals(expiryDate)) { ret = true;/*from w w w . j ava 2 s .co m*/ } return ret; }
From source file:com.devnexus.ting.web.controller.ScheduleController.java
private void prepareScheduleAsPdf(Event event, HttpServletResponse response, boolean userSchedule) throws IOException { final String pdfFileName = event.getEventKey() + "-schedule.pdf"; response.setContentType("application/pdf"); final String headerKey = "Content-Disposition"; final String headerValue = String.format("attachment; filename=\"%s\"", pdfFileName); response.setHeader(headerKey, headerValue); final ScheduleItemList scheduleItemList = businessService.getScheduleForEvent(event.getId()); final SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE MMMM d, yyyy"); final SimpleDateFormat timeFormat = new SimpleDateFormat("kk:mm"); final String eventTitle; if (userSchedule) { eventTitle = "My Schedule for " + event.getTitle(); } else {/* w ww. j ava 2 s . c o m*/ eventTitle = event.getTitle(); } final PdfUtils pdfUtils = new PdfUtils(72f, eventTitle); try { for (Date conferenceDay : scheduleItemList.getDays()) { pdfUtils.println(); pdfUtils.println(dateFormat.format(conferenceDay)); pdfUtils.println(); Date fromTimeslot = null; for (ScheduleItem scheduleItem : scheduleItemList.findHeaderItemsOnDate(conferenceDay)) { if (fromTimeslot == null || !fromTimeslot.equals(scheduleItem.getFromTime())) { fromTimeslot = scheduleItem.getFromTime(); pdfUtils.print(timeFormat.format(fromTimeslot) + " " + timeFormat.format(scheduleItem.getToTime())); } final String title = scheduleItem.getPresentation() != null ? scheduleItem.getPresentation().getTitle() : scheduleItem.getTitle(); pdfUtils.print(105f, scheduleItem.getRoom().getName()); if (scheduleItem.getPresentation() != null && scheduleItem.getPresentation().getTrack() != null && "misc".equalsIgnoreCase(scheduleItem.getPresentation().getTrack().getName())) { pdfUtils.print(150f, scheduleItem.getPresentation().getTrack().getName()); pdfUtils.print(60f, ""); } else { pdfUtils.print(150f, ""); } pdfUtils.println(title); } for (ScheduleItem scheduleItem : scheduleItemList.findBreakoutItemsOnDate(conferenceDay)) { if (userSchedule && !scheduleItem.isFavorite()) { continue; } if (fromTimeslot == null || !fromTimeslot.equals(scheduleItem.getFromTime())) { fromTimeslot = scheduleItem.getFromTime(); pdfUtils.println(); pdfUtils.println(timeFormat.format(fromTimeslot) + " " + timeFormat.format(scheduleItem.getToTime())); pdfUtils.println(); } pdfUtils.print(scheduleItem.getRoom().getName(), scheduleItem.getRoom().getColor()); if (scheduleItem.getPresentation() != null && scheduleItem.getPresentation().getTrack() != null) { pdfUtils.print(105f, scheduleItem.getPresentation().getTrack().getName()); pdfUtils.print(150f, ""); } else { pdfUtils.print(265f, ""); } final String title = scheduleItem.getPresentation() != null ? scheduleItem.getPresentation().getTitle() : "N/A"; pdfUtils.println(title); } } pdfUtils.done(response.getOutputStream()); } finally { pdfUtils.getDoc().close(); } }
From source file:org.apache.ranger.plugin.conditionevaluator.RangerScriptExecutionContext.java
public boolean isAccessedAfter(String tagType, String attributeName) { boolean ret = false; Date accessDate = getAccessTime(); Date expiryDate = getTagAttributeAsDate(tagType, attributeName); if (expiryDate == null || accessDate.after(expiryDate) || accessDate.equals(expiryDate)) { ret = true;//w ww . ja va2s. c om } return ret; }
From source file:no.abmu.questionnaire.domain.data.DateFieldData.java
public void setDateValue(Date date) { // logger.debug("Executing setDateValue as Date date=[" + date + "] for code=[" + getCode() + "]"); if (date == null) { if (this.dateValue != null) { this.dateValue = null; }/*from ww w. j ava 2 s . c o m*/ return; } if (date.equals(this.dateValue)) { return; } this.dateValue = date; }
From source file:com.keedio.nifi.processors.azure.blob.PutAzureBlobObjectTest.java
@Test public void testPutAzureBlobObjectProcessorOverride() throws IOException, ParseException, InitializationException, InterruptedException, InvalidKeyException, StorageException, URISyntaxException { CloudBlobWrapper blob = null;//from ww w.j a v a 2s. co m try { String connectionString = System.getProperty("storageConnectionString"); String containerName = System.getProperty("containerName"); Assume.assumeTrue(StringUtils.isNoneEmpty(connectionString, containerName)); AzureBlobConnectionService connectionService = new AzureBlobConnectionServiceImpl(); Map<String, String> controllerProperties = new HashMap<>(); controllerProperties.put(AZURE_STORAGE_CONNECTION_STRING.getName(), connectionString); controllerProperties.put(AZURE_STORAGE_CONTAINER_NAME.getName(), containerName); testRunner.addControllerService("my-put-test-connection-service", connectionService, controllerProperties); testRunner.enableControllerService(connectionService); testRunner.assertValid(connectionService); testRunner.setProperty(AZURE_STORAGE_CONTROLLER_SERVICE, connectionService.getIdentifier()); Date now = new Date(); Thread.sleep(1100); testRunner.setProperty(AZURE_STORAGE_BEHAVIOUR_IF_BLOB_EXISTS, "overwrite"); final String DYNAMIC_ATTRIB_KEY_1 = "runTimestamp"; final String DYNAMIC_ATTRIB_VALUE_1 = String.valueOf(System.nanoTime()); final String DYNAMIC_ATTRIB_KEY_2 = "testUploader"; final String DYNAMIC_ATTRIB_VALUE_2 = "KEEDIO"; PropertyDescriptor testAttrib1 = processor.getSupportedDynamicPropertyDescriptor(DYNAMIC_ATTRIB_KEY_1); testRunner.setProperty(testAttrib1, DYNAMIC_ATTRIB_VALUE_1); PropertyDescriptor testAttrib2 = processor.getSupportedDynamicPropertyDescriptor(DYNAMIC_ATTRIB_KEY_2); testRunner.setProperty(testAttrib2, DYNAMIC_ATTRIB_VALUE_2); final Map<String, String> attrs = new HashMap<>(); attrs.put(CoreAttributes.FILENAME.key(), TEST_PUT_AZURE_BLOB_OBJECT_BLOCKBLOB_TMP); testRunner.enqueue(getResourcePath("/blockblob.tmp"), attrs); testRunner.assertValid(); testRunner.run(1); testRunner.assertAllFlowFilesTransferred(REL_SUCCESS, 1); MockFlowFile mockFlowFile = testRunner.getFlowFilesForRelationship(REL_SUCCESS).get(0); Map<String, String> attributes = mockFlowFile.getAttributes(); assertTrue(attributes.size() >= 3); assertEquals(TEST_PUT_AZURE_BLOB_OBJECT_BLOCKBLOB_TMP, attributes.get("metadata.blobName")); assertEquals("blobbasics3d8a33d05e7940dabbb92476fc4fb345", attributes.get("metadata.containerName")); assertNotNull(attributes.get("property.lastModified")); Date lastModified = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT .parse(attributes.get("property.lastModified")); assertTrue(lastModified.after(now) || lastModified.equals(now)); assertTrue(Long.parseLong(attributes.get("property.length")) >= 0); assertFalse(attributes.containsKey("property.contentDisposition")); assertFalse(attributes.containsKey("property.copyState")); File localTestFile = new File("src/test/resources/blockblob.tmp"); mockFlowFile.assertContentEquals(localTestFile); blob = new CloudBlobWrapper(TEST_PUT_AZURE_BLOB_OBJECT_BLOCKBLOB_TMP, connectionService.getCloudBlobContainerReference()); try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { blob.download(os); assertEquals(localTestFile.length(), os.toByteArray().length); } } finally { if (blob != null) blob.deleteIfExists(); } }
From source file:org.seasar.mayaa.impl.engine.specification.SpecificationImpl.java
public boolean isDeprecated() { if (_deprecated == false) { _deprecated = _hasSource != isSourceExists(); if (_deprecated == false) { if (_hasSource == false) { return false; }/*from w w w . j a v a2 s . c o m*/ _deprecated = (getTimestamp() == null); if (_deprecated == false) { if (needCheckTimestamp() == false) { return false; } Date sourceTime = getSource().getTimestamp(); // ???? _deprecated = sourceTime.equals(_builtSourceTime) == false; } } } return _deprecated; }
From source file:com.virtusa.akura.student.controller.StudentAttendenceController.java
/** * generate student attendance detail for given time range in studentTemplate. map key contains date and * value contains attendance status as AttendeceStatus object. * /*from w ww .j a v a2s . c om*/ * @param studentTemplate time rage as template * @param studentId for given studentId(primary key) * @param modelMap - a hash map related to the student attendance. * @return map with attendant status * @throws AkuraAppException when exception occurs */ private Map<String, AttendeceStatus> getAllAttendanceStatus(StudentWiseSwipInOutTemplate studentTemplate, int studentId, ModelMap modelMap) throws AkuraAppException { Date from = DateUtil.getParseDate(studentTemplate.getDateFrom()); Date to = DateUtil.getParseDate(studentTemplate.getDateTo()); Map<String, AttendeceStatus> allDays = new TreeMap<String, AttendeceStatus>(); // if the start date of the student is less than the attendance search from date, // save or edit. Date startedDate = studentService.getStudentStartedDate(studentId); if (startedDate != null && from.after(startedDate) || (startedDate != null && startedDate.equals(from))) { // map contains all the days with absent in default allDays = getDaysWithoutHolydays(from, to); // to overwrite the "allDays" map values for absent with a reason List<StudentLeave> leaveList = studentService.findAlreadyExistLeave(studentId, from, to); for (StudentLeave leave : leaveList) { Date leaveFrom = leave.getFromDate(); Date leaveTo = leave.getToDate(); for (Entry<String, AttendeceStatus> entry : allDays.entrySet()) { Date day = DateUtil.getParseDate(entry.getKey()); if (day.equals(leaveFrom) || day.equals(leaveTo) || (day.after(leaveFrom) && day.before(leaveTo))) { entry.getValue().setDescription(leave.getReason()); } } } // to overwrite the "allDays" map values for attended days List<DailyStudentAttendance> dalyAttendList = dailyAttendanceService.getAttendanceBettween(studentId, from, to); for (DailyStudentAttendance dalyAttend : dalyAttendList) { String dayKey = DateUtil.getFormatDate(dalyAttend.getDate()); if (allDays.containsKey(dayKey)) { AttendeceStatus attendStatus = allDays.get(dayKey); attendStatus.setAbsent(false); attendStatus.setTimeIn(dalyAttend.getTimeIn()); attendStatus.setTimeOut(dalyAttend.getTimeOut()); } } } else { String message = new ErrorMsgLoader().getErrorMessage(STUDENT_FIRST_DATE_ATTENDANCE_ERROR); modelMap.addAttribute(MESSAGE, message); } return allDays; }
From source file:com.mobileman.projecth.business.impl.PatientMedicationServiceImpl.java
/** * {@inheritDoc}//from w w w . j av a 2 s . co m * @see com.mobileman.projecth.business.PatientMedicationService#addConsumedMedication(java.lang.Long, java.lang.Long, java.lang.Long, double, com.mobileman.projecth.domain.util.medication.MedicationFrequency, java.util.Date, java.util.Date, java.lang.String) */ @Override public void addConsumedMedication(Long patientId, Long diseaseId, Long medicationId, double standarUnitsTaken, MedicationFrequency frequency, Date startDate, Date endDate, String comment) throws IllegalArgumentException { if (log.isDebugEnabled()) { log.debug("addConsumedMedication(" + patientId + ", " + diseaseId + ", " + medicationId + ", " + standarUnitsTaken + ", " + frequency + ", " + startDate + ", " + endDate + ") - start"); //$NON-NLS-1$ } if (patientId == null) { throw new IllegalArgumentException("patientId must not be null"); } if (diseaseId == null) { throw new IllegalArgumentException("diseaseId must not be null"); } if (medicationId == null) { throw new IllegalArgumentException("medicationId must not be null"); } if (standarUnitsTaken <= 0.0d) { throw new IllegalArgumentException("standarUnitsTaken must not be zero or negative value"); } if (frequency == null) { throw new IllegalArgumentException("frequency must not be null"); } if (endDate == null) { endDate = startDate; } Patient patient = patientDao.findById(patientId); patient.setLastUpdate(new Date()); Medication medication = medicationDao.findById(medicationId); Disease disease = diseaseDao.findById(diseaseId); Date date = startDate; Calendar calendar = new GregorianCalendar(); calendar.setTime(startDate); Date timestamp = new Date(); while (date.before(endDate) || date.equals(endDate)) { PatientMedication patientMedication = new PatientMedication(); patientMedication.setTimestamp(timestamp); patientMedication.setPatient(patient); patientMedication.setMedication(medication); patientMedication.setComment(comment); patientMedication.setConsumptionDate(date); patientMedication.setDisease(disease); patientMedication.setAmount(new BigDecimal(standarUnitsTaken)); patientMedicationDao.save(patientMedication); if (frequency.equals(MedicationFrequency.ONE_TIME)) { break; } switch (frequency) { case DAILY: calendar.add(Calendar.DAY_OF_YEAR, 1); break; case WEEKLY: calendar.add(Calendar.WEEK_OF_YEAR, 1); break; case BI_WEEKLY: calendar.add(Calendar.WEEK_OF_YEAR, 2); break; default: break; } date = calendar.getTime(); } if (log.isDebugEnabled()) { log.debug("addConsumedMedication(Long, Long, Long, double) - returns"); //$NON-NLS-1$ } }
From source file:org.motechproject.server.service.TetanusScheduleTest.java
public void testCreateFirstDose() { Date date = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date);// w ww . ja v a 2 s. co m calendar.add(Calendar.YEAR, -30); // age is 30 years Patient patient = new Patient(); patient.setGender("F"); patient.setBirthdate(calendar.getTime()); Capture<Date> dueDateCapture = new Capture<Date>(); Capture<Date> lateDateCapture = new Capture<Date>(); List<Obs> obsList = new ArrayList<Obs>(); List<ExpectedObs> expectedObsList = new ArrayList<ExpectedObs>(); expect(registrarBean.getObs(patient, ttSchedule.getConceptName(), ttSchedule.getValueConceptName(), patient.getBirthdate())).andReturn(obsList); expect(registrarBean.getExpectedObs(patient, ttSchedule.getName())).andReturn(expectedObsList); expect(registrarBean.createExpectedObs(eq(patient), eq(ttSchedule.getConceptName()), eq(ttSchedule.getValueConceptName()), eq(tt1Event.getNumber()), (Date) anyObject(), capture(dueDateCapture), capture(lateDateCapture), (Date) anyObject(), eq(tt1Event.getName()), eq(ttSchedule.getName()))).andReturn(new ExpectedObs()); replay(registrarBean); ttSchedule.updateSchedule(patient, date); verify(registrarBean); Date dueDate = dueDateCapture.getValue(); Date lateDate = lateDateCapture.getValue(); assertNotNull("Due date is null", dueDate); assertNotNull("Late date is null", lateDate); assertTrue("Late date not equal to due date", lateDate.equals(dueDate)); }
From source file:org.jolokia.jvmagent.handler.JolokiaHttpHandlerTest.java
@Test public void testCallbackPost() throws URISyntaxException, IOException, java.text.ParseException { HttpExchange exchange = prepareExchange("http://localhost:8080/jolokia?callback=data", "Content-Type", "text/plain; charset=UTF-8", "Origin", null); // Simple GET method prepareMemoryPostReadRequest(exchange); Headers header = new Headers(); ByteArrayOutputStream out = prepareResponse(handler, exchange, header); handler.doHandle(exchange);/*w w w. j a va2 s. c om*/ assertEquals(header.getFirst("content-type"), "text/javascript; charset=utf-8"); String result = out.toString("utf-8"); assertTrue(result.endsWith("});")); assertTrue(result.startsWith("data({")); assertTrue(result.contains("\"used\"")); assertEquals(header.getFirst("Cache-Control"), "no-cache"); assertEquals(header.getFirst("Pragma"), "no-cache"); SimpleDateFormat rfc1123Format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT")); String expires = header.getFirst("Expires"); String date = header.getFirst("Date"); Date parsedExpires = rfc1123Format.parse(expires); Date parsedDate = rfc1123Format.parse(date); assertTrue(parsedExpires.before(parsedDate) || parsedExpires.equals(parsedDate)); Date now = new Date(); assertTrue(parsedExpires.before(now) || parsedExpires.equals(now)); }