List of usage examples for java.util GregorianCalendar add
@Override public void add(int field, int amount)
From source file:op.tools.SYSCalendar.java
public static GregorianCalendar Pfingstmontag(int year) { GregorianCalendar gc = Ostersonntag(year); gc.add(GregorianCalendar.DAY_OF_MONTH, 50); return gc;//from w w w.java2 s .c o m }
From source file:op.tools.SYSCalendar.java
public static GregorianCalendar ChristiHimmelfahrt(int year) { GregorianCalendar gc = Ostersonntag(year); gc.add(GregorianCalendar.DAY_OF_MONTH, 39); return gc;/*from w w w . ja va 2 s . com*/ }
From source file:op.tools.SYSCalendar.java
public static GregorianCalendar Fronleichnam(int year) { GregorianCalendar gc = Ostersonntag(year); gc.add(GregorianCalendar.DAY_OF_MONTH, 60); return gc;//from w w w . j av a 2s . co m }
From source file:se.inera.axel.shs.broker.messagestore.internal.AbstractMongoMessageLogTest.java
@BeforeMethod public void setupTestDB() throws IOException { mongoDbFactory.getDb().dropDatabase(); Maker<se.inera.axel.shs.mime.ShsMessage> asynchMessage = a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(transferType, TransferType.ASYNCH)))); messageLogService.saveMessage(make(asynchMessage)); messageLogService.saveMessage(make(asynchMessage)); messageLogService.messageSent(messageLogService.saveMessage(make(asynchMessage))); messageLogService.messageReceived(messageLogService.saveMessage( make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(transferType, TransferType.SYNCH))))))); messageLogService.messageReceived(messageLogService.saveMessage(make(asynchMessage))); messageLogService.messageReceived(messageLogService.saveMessage(make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(to, a(To, with(To.value, ShsLabelMaker.DEFAULT_TEST_FROM))), with(transferType, TransferType.ASYNCH))))))); messageLogService.messageReceived(messageLogService.saveMessage(make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(product, a(Product, with(Product.value, "error"))), with(sequenceType, SequenceType.ADM), with(transferType, TransferType.ASYNCH))))))); messageLogService.messageReceived(messageLogService.saveMessage(make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(product, a(Product, with(Product.value, "confirm"))), with(sequenceType, SequenceType.ADM), with(transferType, TransferType.ASYNCH))))))); messageLogService.messageReceived(messageLogService.saveMessage(make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(transferType, TransferType.ASYNCH), with(status, Status.TEST))))))); messageLogService.messageAcknowledged( messageLogService.messageReceived(messageLogService.saveMessage(make(asynchMessage)))); messageLogService.messageReceived(messageLogService.saveMessage(make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(to, a(To, with(To.value, ShsLabelMaker.DEFAULT_TEST_FROM))), with(endRecipient,//ww w. j a v a 2s . co m a(EndRecipient, with(EndRecipient.value, ShsLabelMaker.DEFAULT_TEST_ENDRECIPIENT))), with(transferType, TransferType.ASYNCH))))))); messageLogService.messageReceived(messageLogService.saveMessage(make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(to, a(To, with(To.value, ShsLabelMaker.DEFAULT_TEST_FROM))), with(corrId, "testing-corrid"), with(transferType, TransferType.ASYNCH))))))); messageLogService.messageReceived(messageLogService.saveMessage(make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(to, a(To, with(To.value, ShsLabelMaker.DEFAULT_TEST_FROM))), with(transferType, TransferType.ASYNCH), with(content, a(Content, with(Content.contentId, "testing-contentid"))))))))); messageLogService.messageReceived(messageLogService.saveMessage(make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(to, a(To, with(To.value, ShsLabelMaker.DEFAULT_TEST_FROM))), with(transferType, TransferType.ASYNCH), with(meta, listOf(a(Meta, with(Meta.name, "namn"), with(Meta.value, "varde")))))))))); messageLogService.messageReceived(messageLogService.saveMessage(make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(originatorOrFrom, listOf(a(Originator, with(Originator.value, ShsLabelMaker.DEFAULT_TEST_ORIGINATOR)))), with(to, a(To, with(To.value, ShsLabelMaker.DEFAULT_TEST_FROM))), with(transferType, TransferType.ASYNCH))))))); ShsMessageEntry entry = messageLogService.messageReceived(messageLogService.saveMessage(make(a(ShsMessage, with(ShsMessage.label, a(ShsLabel, with(to, a(To, with(To.value, ShsLabelMaker.DEFAULT_TEST_FROM))), with(subject, "lastWeeksMessage"), with(transferType, TransferType.ASYNCH))))))); //config for message "entry" GregorianCalendar lastWeek = new GregorianCalendar(); lastWeek.add(GregorianCalendar.DAY_OF_MONTH, -7); entry.setStateTimeStamp(lastWeek.getTime()); messageLogService.update(entry); entry = messageLogService.saveMessage(make(asynchMessage)); messageLogService.update(entry); mongoOperations.indexOps(ShsMessageEntry.class) .ensureIndex(new Index().on("label.txId", Sort.Direction.ASC).unique()); }
From source file:com.vmware.appfactory.common.runner.LicenseStatus.java
/** * Find out whether license is expired or not using yesterday midnight. * Calculate the number of days until expiration. *//*from w ww. j av a 2s.co m*/ private final void calculateNumDaysToExpiration() { final GregorianCalendar gCal = new GregorianCalendar(AfCalendar.LOCAL_TZONE); gCal.add(Calendar.DATE, -1); final Date yesterdayMidnight = DateUtils.round(gCal.getTime(), Calendar.HOUR); setNumDaysToExpiration( (_expirationDate.getTime() - yesterdayMidnight.getTime()) / DateUtils.MILLIS_PER_DAY); if (getNumDaysToExpiration() <= 0) { _isExpired = true; } else { _isExpired = false; } }
From source file:org.motechproject.mobile.omp.manager.intellivr.ConvertSerializedIVRSessionsBean.java
private Date addToDate(Date start, int field, int amount) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(start);/* www . j a v a 2 s.co m*/ cal.add(field, amount); return cal.getTime(); }
From source file:org.openmrs.module.pmtct.PregnancyDateManager.java
@SuppressWarnings("deprecation") public String getDPA(String dateOfPeriod) throws Exception { Date lastDateOfPeriod = Context.getDateFormat().parse(dateOfPeriod); GregorianCalendar last_DateOfPeriod = new GregorianCalendar(lastDateOfPeriod.getYear() + 1900, lastDateOfPeriod.getMonth(), lastDateOfPeriod.getDate()); last_DateOfPeriod.setLenient(false); last_DateOfPeriod.add(Calendar.DAY_OF_YEAR, PMTCTConstants.DELAY_IN_DAYS_OF_PREGNANCY); return Context.getDateFormat().format(last_DateOfPeriod.getTime()); }
From source file:de.arago.rike.task.action.EvaluateTask.java
@Override public void execute(IDataWrapper data) throws Exception { if (data.getRequestAttribute("id") != null) { Task task = TaskHelper.getTask(data.getRequestAttribute("id")); String user = SecurityHelper.getUserEmail(data.getUser()); if (task.getStatusEnum() == Task.Status.UNKNOWN || task.getStatusEnum() == Task.Status.OPEN) { task.setMilestone(/*from www .j av a 2s. co m*/ new DataHelperRike<Milestone>(Milestone.class).find(data.getRequestAttribute("milestone"))); task.setArtifact( new DataHelperRike<Artifact>(Artifact.class).find(data.getRequestAttribute("artifact"))); task.setDescription(data.getRequestAttribute("description")); try { task.setSizeEstimated(Integer.valueOf(data.getRequestAttribute("size_estimated"), 10)); } catch (Exception ignored) { } try { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); task.setDueDate(format.parse(data.getRequestAttribute("due_date"))); } catch (Exception ignored) { } task.setTitle(data.getRequestAttribute("title")); task.setUrl(data.getRequestAttribute("url")); int priority = Integer.parseInt(GlobalConfig.get(PRIORITY_NORMAL)); try { priority = Integer.valueOf(data.getRequestAttribute("priority"), 10); } catch (Exception ignored) { } task.setPriority(priority); task.setRated(new Date()); task.setRatedBy(user); task.setStatus(Task.Status.OPEN); if (GlobalConfig.get(WORKFLOW_TYPE).equalsIgnoreCase("arago Technologies") && priority == 1) { GregorianCalendar c = new GregorianCalendar(); c.setTime(task.getRated()); c.add(Calendar.DAY_OF_MONTH, Integer.parseInt(GlobalConfig.get(WORKFLOW_DAYS_TOP_PRIO_TASK))); task.setDueDate(c.getTime()); } TaskHelper.save(task); StatisticHelper.update(); data.setSessionAttribute("task", task); HashMap<String, Object> notificationParam = new HashMap<String, Object>(); notificationParam.put("id", data.getRequestAttribute("id")); data.setEvent("TaskUpdateNotification", notificationParam); data.removeSessionAttribute("targetView"); ActivityLogHelper.log( " rated Task #" + task.getId() + " <a href=\"/web/guest/rike/-/show/task/" + task.getId() + "\">" + StringEscapeUtils.escapeHtml(task.getTitle()) + "</a> ", task.getStatus(), SecurityHelper.getUserEmail(data.getUser()), data, task.toMap()); } } }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.group.BookingRoomAjaxController.java
@Override public Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception { Map map = new HashMap<String, Object>(); GroupMultiController.setPermissionToRequestGroupRole(map, personDao.getLoggedPerson()); if (request.getParameter("type").compareTo("info") == 0) { int id = Integer.parseInt(request.getParameter("id")); Reservation reservation = reservationDao.getReservationById(id); GregorianCalendar created = new GregorianCalendar(); created.setTime(reservation.getCreationTime()); GregorianCalendar startTime = new GregorianCalendar(); startTime.setTime(reservation.getStartTime()); GregorianCalendar endTime = new GregorianCalendar(); endTime.setTime(reservation.getEndTime()); Map data = new HashMap<String, Object>(); data.put("id", id); data.put("person", reservation.getPerson()); data.put("created", BookingRoomUtils.getDate(created) + ", " + BookingRoomUtils.getTime(created)); data.put("date", BookingRoomUtils.getDate(startTime)); data.put("start", BookingRoomUtils.getHoursAndMinutes(startTime)); data.put("end", BookingRoomUtils.getHoursAndMinutes(endTime)); map.put("data", data); return map; }/*w ww . j av a 2s . c o m*/ if (request.getParameter("type").compareTo("delete") == 0) { int id = Integer.parseInt(request.getParameter("id")); if (reservationDao.deleteReservation(id)) { map.put("status", messageSource.getMessage("bookRoom.delete.success", null, RequestContextUtils.getLocale(request))); } else { map.put("status", messageSource.getMessage("bookRoom.delete.error", null, RequestContextUtils.getLocale(request))); } return map; } if (request.getParameter("type").compareTo("timeline") == 0) { String date = request.getParameter("date") + " 00:00:00"; log.debug("XML DATE=" + date); GregorianCalendar monthStart = BookingRoomUtils.getCalendar(date); monthStart.set(Calendar.DAY_OF_MONTH, 1); GregorianCalendar monthEnd = (GregorianCalendar) monthStart.clone(); monthEnd.add(Calendar.MONTH, 1); monthEnd.add(Calendar.SECOND, -1); String xml = BookingRoomXmlUtils.formatReservationsList( reservationDao.getReservationsBetween(monthStart, monthEnd), personDao.getLoggedPerson()); map.put("xmlContent", xml); return map; } throw new InvalidAttributeValueException( "Attribute '" + request.getParameter("type") + "' is not allowed!"); }
From source file:org.chililog.server.pubsub.jsonhttp.PublicationWorker.java
/** * Authenticate request/*from w w w.j a v a 2 s . c o m*/ * * @param publicationAO * @throws ChiliLogException */ public void authenticate(PublicationRequestAO publicationAO) throws ChiliLogException { String repoName = publicationAO.getRepositoryName(); // Check cache String key = String.format("%s_%s_%s", repoName, publicationAO.getUsername(), publicationAO.getPassword()); Date expiry = _authenticationCache.get(key); if (expiry != null && expiry.after(new Date())) { // Validate return; } // Check db DB db = MongoConnection.getInstance().getConnection(); // Make user repository exists RepositoryConfigController.getInstance().getByName(db, repoName); // Make sure user exists and password is valid UserBO user = UserController.getInstance().getByUsername(db, publicationAO.getUsername()); boolean passwordOK = false; if (publicationAO.getPassword().startsWith("token:")) { // Password is a token so we need to check the token // Must have come from the workbench String jsonToken = publicationAO.getPassword().substring(6); AuthenticationTokenAO token = AuthenticationTokenAO.fromString(jsonToken); passwordOK = token.getUserID().equals(user.getDocumentID().toString()); } else { // Make sure user exists and password is valid passwordOK = user.validatePassword(publicationAO.getPassword()); } if (!passwordOK) { throw new ChiliLogException(Strings.PUBLISHER_AUTHENTICATION_ERROR); } // Make sure the user can publish to the repository String administratorRole = UserBO.createRepositoryAdministratorRoleName(repoName); String workbenchRole = UserBO.createRepositoryWorkbenchRoleName(repoName); String publicationRole = UserBO.createRepositoryPublisherRoleName(repoName); if (!user.hasRole(administratorRole) && !user.hasRole(publicationRole) && !user.hasRole(workbenchRole) && !user.isSystemAdministrator()) { throw new ChiliLogException(Strings.PUBLISHER_AUTHENTICATION_ERROR); } // Cache details GregorianCalendar newExpiry = new GregorianCalendar(); newExpiry.add(Calendar.MILLISECOND, AppProperties.getInstance().getMqSecurityInvalidationInterval()); _authenticationCache.put(key, newExpiry.getTime()); }