List of usage examples for org.joda.time DateTime plusMinutes
public DateTime plusMinutes(int minutes)
From source file:com.sonicle.webtop.calendar.CalendarManager.java
License:Open Source License
public ArrayList<String> generateTimeSpans(int minRange, LocalDate fromDate, LocalDate toDate, LocalTime fromTime, LocalTime toTime, DateTimeZone tz) { ArrayList<String> hours = new ArrayList<>(); DateTimeFormatter ymdhmZoneFmt = DateTimeUtils.createYmdHmFormatter(tz); DateTime instant = new DateTime(tz).withDate(fromDate).withTime(fromTime).withSecondOfMinute(0) .withMillisOfSecond(0);//from ww w .ja va2 s. c o m DateTime boundaryInstant = new DateTime(tz).withDate(toDate).withTime(toTime).withSecondOfMinute(0) .withMillisOfSecond(0); while (instant.compareTo(boundaryInstant) < 0) { hours.add(ymdhmZoneFmt.print(instant)); instant = instant.plusMinutes(minRange); } return hours; }
From source file:com.thoughtworks.go.helper.JobInstanceMother.java
License:Apache License
public static JobInstance buildEndingWithState(JobState endState, JobResult result, String jobConfig) { final JobInstance instance = new JobInstance(jobConfig); instance.setAgentUuid("1234"); instance.setId(1L);//w w w .j a v a 2s . c o m instance.setIdentifier(defaultJobIdentifier(jobConfig)); instance.setState(endState); instance.setTransitions(new JobStateTransitions()); DateTime now = new DateTime(); Date scheduledDate = now.minusMinutes(5).toDate(); instance.setScheduledDate(scheduledDate); List<JobState> orderedStates = orderedBuildStates(); DateTime stateDate = new DateTime(scheduledDate); for (JobState stateToCompareTo : orderedStates) { if (endState.compareTo(stateToCompareTo) >= 0) { instance.changeState(stateToCompareTo, stateDate.toDate()); stateDate = stateDate.plusMinutes(1); } } if (endState.equals(JobState.Completed)) { instance.setResult(result); } return instance; }
From source file:com.tremolosecurity.provisioning.tasks.Approval.java
License:Apache License
public Approval(WorkflowTaskType taskConfig, ConfigManager cfg, Workflow wf) throws ProvisioningException { super(taskConfig, cfg, wf); this.approvers = new ArrayList<Approver>(); this.azRules = new ArrayList<AzRule>(); this.failed = false; ApprovalType att = (ApprovalType) taskConfig; for (AzRuleType azr : att.getApprovers().getRule()) { Approver approver = new Approver(); if (azr.getScope().equalsIgnoreCase("filter")) { approver.type = ApproverType.Filter; } else if (azr.getScope().equalsIgnoreCase("group")) { approver.type = ApproverType.StaticGroup; } else if (azr.getScope().equalsIgnoreCase("dn")) { approver.type = ApproverType.DN; } else if (azr.getScope().equalsIgnoreCase("dynamicGroup")) { approver.type = ApproverType.DynamicGroup; } else if (azr.getScope().equalsIgnoreCase("custom")) { approver.type = ApproverType.Custom; }/*from w w w. j a v a 2 s.com*/ approver.constraint = azr.getConstraint(); setupCustomParameters(approver); this.approvers.add(approver); AzRule rule = new AzRule(azr.getScope(), azr.getConstraint(), azr.getClassName(), cfg, wf); this.azRules.add(rule); approver.customAz = rule.getCustomAuthorization(); } this.label = att.getLabel(); this.emailTemplate = att.getEmailTemplate(); this.mailAttr = att.getMailAttr(); this.failureEmailSubject = att.getFailureEmailSubject(); this.failureEmailMsg = att.getFailureEmailMsg(); this.escalationRules = new ArrayList<EscalationRule>(); if (att.getEscalationPolicy() != null) { DateTime now = new DateTime(); for (EscalationType ert : att.getEscalationPolicy().getEscalation()) { EscalationRule erule = new EsclationRuleImpl(); DateTime when; if (ert.getExecuteAfterUnits().equalsIgnoreCase("sec")) { when = now.plusSeconds(ert.getExecuteAfterTime()); } else if (ert.getExecuteAfterUnits().equals("min")) { when = now.plusMinutes(ert.getExecuteAfterTime()); } else if (ert.getExecuteAfterUnits().equals("hr")) { when = now.plusHours(ert.getExecuteAfterTime()); } else if (ert.getExecuteAfterUnits().equals("day")) { when = now.plusDays(ert.getExecuteAfterTime()); } else if (ert.getExecuteAfterUnits().equals("wk")) { when = now.plusWeeks(ert.getExecuteAfterTime()); } else { throw new ProvisioningException("Unknown time unit : " + ert.getExecuteAfterUnits()); } erule.setCompleted(false); erule.setExecuteTS(when.getMillis()); if (ert.getValidateEscalationClass() != null && !ert.getValidateEscalationClass().isEmpty()) { try { erule.setVerify( (VerifyEscalation) Class.forName(ert.getValidateEscalationClass()).newInstance()); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new ProvisioningException("Could not initialize escalation rule", e); } } else { erule.setVerify(null); } erule.setAzRules(new ArrayList<AzRule>()); for (AzRuleType azr : ert.getAzRules().getRule()) { Approver approver = new Approver(); if (azr.getScope().equalsIgnoreCase("filter")) { approver.type = ApproverType.Filter; } else if (azr.getScope().equalsIgnoreCase("group")) { approver.type = ApproverType.StaticGroup; } else if (azr.getScope().equalsIgnoreCase("dn")) { approver.type = ApproverType.DN; } else if (azr.getScope().equalsIgnoreCase("dynamicGroup")) { approver.type = ApproverType.DynamicGroup; } else if (azr.getScope().equalsIgnoreCase("custom")) { approver.type = ApproverType.Custom; } approver.constraint = azr.getConstraint(); setupCustomParameters(approver); //this.approvers.add(approver); AzRule rule = new AzRule(azr.getScope(), azr.getConstraint(), azr.getClassName(), cfg, wf); erule.getAzRules().add(rule); approver.customAz = rule.getCustomAuthorization(); } this.escalationRules.add(erule); now = when; } if (att.getEscalationPolicy().getEscalationFailure().getAction() != null) { switch (att.getEscalationPolicy().getEscalationFailure().getAction()) { case "leave": this.failureAzRules = null; this.failOnNoAZ = false; break; case "assign": this.failOnNoAZ = true; this.failureAzRules = new ArrayList<AzRule>(); for (AzRuleType azr : att.getEscalationPolicy().getEscalationFailure().getAzRules().getRule()) { Approver approver = new Approver(); if (azr.getScope().equalsIgnoreCase("filter")) { approver.type = ApproverType.Filter; } else if (azr.getScope().equalsIgnoreCase("group")) { approver.type = ApproverType.StaticGroup; } else if (azr.getScope().equalsIgnoreCase("dn")) { approver.type = ApproverType.DN; } else if (azr.getScope().equalsIgnoreCase("dynamicGroup")) { approver.type = ApproverType.DynamicGroup; } else if (azr.getScope().equalsIgnoreCase("custom")) { approver.type = ApproverType.Custom; } approver.constraint = azr.getConstraint(); setupCustomParameters(approver); //this.approvers.add(approver); AzRule rule = new AzRule(azr.getScope(), azr.getConstraint(), azr.getClassName(), cfg, wf); this.failureAzRules.add(rule); approver.customAz = rule.getCustomAuthorization(); } break; default: throw new ProvisioningException("Unknown escalation failure action : " + att.getEscalationPolicy().getEscalationFailure().getAction()); } } } }
From source file:com.webarch.common.datetime.DateTimeUtils.java
License:Apache License
/** * ?/*from w w w . j a v a 2s .c o m*/ * * @param date ? * @param after ?? * @param timeUnit ?? * @return ?? */ public static Date getAfterDate(Date date, final int after, final int timeUnit) { DateTime dateTime = new DateTime(date); Date result; switch (timeUnit) { case YEAR_UNIT: result = dateTime.plusYears(after).toDate(); break; case MONTH_UNIT: result = dateTime.plusMonths(after).toDate(); break; case DAY_UNIT: result = dateTime.plusDays(after).toDate(); break; case HOURE_UNIT: result = dateTime.plusHours(after).toDate(); break; case MINUTE_UNIT: result = dateTime.plusMinutes(after).toDate(); break; default: result = date; } return result; }
From source file:com.zhonghui.tool.controller.GatewayController.java
/** * ??//from w ww . ja va2s .c o m * @param request ???? * @return post??? */ @RequestMapping("/doRecharge") public ModelAndView doRecharge(HttpServletRequest request) { //?properties? SDKConfig config = SDKConfig.getConfig(); //reqData?? Map<String, Object> reqData = new HashMap<String, Object>(); //???? String platformUserNo = request.getParameter("platformUserNo"); String amount = request.getParameter("amount"); String rechargeWay = request.getParameter("rechargeWay"); String bankcode = request.getParameter("bankcode"); String callbackUrl = request.getParameter("callbackUrl"); //??? String requestNo = CgtUtil.getTampTime(); reqData.put("platformUserNo", platformUserNo); reqData.put("requestNo", requestNo); reqData.put("amount", amount); reqData.put("rechargeWay", rechargeWay); reqData.put("bankcode", bankcode); reqData.put("callbackUrl", callbackUrl); //? ?30 DateTime dateTime = new DateTime(); reqData.put("expired", dateTime.plusMinutes(30).toString("yyyyMMddHHmmss")); //?? reqData.put("timestamp", requestNo); Map<String, String> result = null; try { result = CgtUtil.createConnParam("RECHARGE", reqData); } catch (GeneralSecurityException e) { e.printStackTrace(); } String url = "http://220.181.25.233:8602/bha-neo-app/lanmaotech/gateway"; return new ModelAndView("reqeust/gatewayPost").addObject("result", result).addObject("url", url); }
From source file:com.zhonghui.tool.controller.GatewayController.java
/** * ???// w w w.j av a2 s . c om * @param request ???? * @return post??? */ @RequestMapping("/doWithdraw.do") public ModelAndView doWithdraw(HttpServletRequest request) { //?properties? SDKConfig config = SDKConfig.getConfig(); //reqData?? Map<String, Object> reqData = new HashMap<String, Object>(); //???? String platformUserNo = request.getParameter("platformUserNo"); String amount = request.getParameter("amount"); String feeMode = request.getParameter("feeMode"); String withdrawType = request.getParameter("withdrawType"); String callbackUrl = request.getParameter("callbackUrl"); //??? String requestNo = CgtUtil.getTampTime(); reqData.put("platformUserNo", platformUserNo); reqData.put("requestNo", requestNo); reqData.put("amount", amount); reqData.put("feeMode", feeMode); reqData.put("withdrawType", withdrawType); reqData.put("callbackUrl", callbackUrl); //? ?30 DateTime dateTime = new DateTime(); reqData.put("expired", dateTime.plusMinutes(30).toString("yyyyMMddHHmmss")); //?? reqData.put("timestamp", requestNo); Map<String, String> result = null; try { result = CgtUtil.createConnParam("WITHDRAW", reqData); } catch (GeneralSecurityException e) { e.printStackTrace(); } String url = config.getUrl() + GatewayController.GATEWAY; return new ModelAndView("reqeust/gatewayPost").addObject("result", result).addObject("url", url); }
From source file:de.azapps.mirakel.services.TaskService.java
License:Open Source License
private void handleCommand(final Intent intent) { if ((intent == null) || (intent.getAction() == null)) { return;//from www . j av a 2 s. com } final Optional<Task> taskOptional = TaskHelper.getTaskFromIntent(intent); if (!taskOptional.isPresent()) { return; } //reload the task to get the current version final Task task = Task.get(taskOptional.get().getId()).orNull(); if (task == null) { return; } switch (intent.getAction()) { case TASK_DONE: task.setDone(true); task.save(); Toast.makeText(this, getString(R.string.reminder_notification_done_confirm), Toast.LENGTH_LONG).show(); break; case TASK_LATER: final DateTime reminder = new DateTime(); final int addMinutes = MirakelCommonPreferences.getAlarmLater(); reminder.plusMinutes(addMinutes); task.setReminder(Optional.of(reminder)); task.save(); Toast.makeText(this, getString(R.string.reminder_notification_later_confirm, addMinutes), Toast.LENGTH_LONG).show(); break; } stopSelf(); }
From source file:de.chaosfisch.google.youtube.upload.Upload.java
License:Open Source License
@SuppressWarnings("MagicNumber") public void setDateTimeOfRelease(final DateTime dateTimeOfRelease) { if (null == dateTimeOfRelease || dateTimeOfRelease.isBeforeNow()) { this.dateTimeOfRelease = null; } else {//from w w w . ja v a 2 s .c om final int mod = dateTimeOfRelease.getMinuteOfHour() % 30; this.dateTimeOfRelease = dateTimeOfRelease.plusMinutes(16 > mod ? -mod : 30 - mod).minuteOfHour() .roundFloorCopy(); } }
From source file:de.escidoc.bwelabs.depositor.service.SessionManager.java
License:Open Source License
/** * Method checks if the monitoring time of a provided configuration is over. * //from w w w . j ava 2 s . c om * @param configuration * @return */ private static boolean isMonitoringTimeOver(Properties configuration) { String monitoringStartTime = configuration.getProperty(Constants.PROPERTY_MONITORING_START_TIME); if (monitoringStartTime == null) { return false; } DateTimeZone.setDefault(DateTimeZone.UTC); DateTime startTime = new DateTime(monitoringStartTime); String monitoringDuration = configuration.getProperty(Constants.PROPERTY_TIME_MONITORING_DURATION); int monitoringDurationMinutes = Integer.parseInt(monitoringDuration); DateTime endTime = startTime.plusMinutes(monitoringDurationMinutes); return endTime.isBeforeNow(); }
From source file:de.ifgi.fmt.mongo.Store.java
License:Open Source License
/** * //w w w. j a v a 2 s .com * @param args */ public static void main(String[] args) { MongoDB db = MongoDB.getInstance(); db.getMongo().dropDatabase(db.getDatabase()); GeometryFactory gf = new GeometryFactory(); DateTime begin = new DateTime(); Point p = gf.createPoint(new Coordinate(52.0, 7.0)); p.setSRID(4326); User user1 = new User().setUsername("user1").setEmail("user1@fmt.de").setPassword("password1"); User user2 = new User().setUsername("user2").setEmail("user2@fmt.de").setPassword("password2"); User user3 = new User().setUsername("user3").setEmail("user3@fmt.de").setPassword("password3"); Role role1 = new Role().setCategory(Category.EASY).setTitle("Rolle 1").setDescription("Rolle 1") .setMaxCount(200).setMinCount(50).setStartPoint(p).setUsers(Utils.set(user1, user2)); Role role2 = new Role().setCategory(Category.HARD).setTitle("Rolle 2").setDescription("Rolle 2") .setMaxCount(200).setMinCount(40).setStartPoint(p).setUsers(Utils.set(user3)); Trigger t = new Trigger().setTime(begin.plusMinutes(5)); Activity activity = new Activity().setDescription("Activity 1").setTitle("Activity 1").setTrigger(t) .setSignal(new Signal().setType(Type.VIBRATION)) .addTask(role1, new Task().setDescription("Geh nach links")) .addTask(role2, new Task().setDescription("Geh nach rechts")); Flashmob f = new Flashmob().addRole(role1).setCoordinator(user2).addRole(role2).addTrigger(t) .addActivity(activity).setDescription("Was wei ich").setEnd(begin.plusHours(2)).setStart(begin) .setPublic(false).setKey("geheim").setTitle("Ein FlashMob").setLocation(p); activity.addTask(role1, new Task().setDescription("task1")); activity.addTask(role2, new Task().setDescription("task2")); Store s = new Store(); s.users().save(Utils.list(user1, user2, user3)); s.flashmobs().save(f); s.comments().save(new Comment().setText("war ganz dolle").setUser(user1).setTime(begin.minusHours(20)) .setFlashmob(f)); s.comments().save(new Comment().setText("war wirklich ganz dolle").setUser(user2) .setTime(begin.minusHours(19)).setFlashmob(f)); // ObjectId oid = f.getId(); // // // s.users().delete(user1); // // f = s.flashmobs().get(oid); // // try { // System.err.println(JSONFactory.getEncoder(Flashmob.class) // .encode(f, null).toString(4)); // } catch (JSONException e) { // e.printStackTrace(); // } }