org.apache.commons.lang.time.DateUtils Java Examples
The following examples show how to use
org.apache.commons.lang.time.DateUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CibaPingModeJwtAuthRequestTests.java From oxAuth with MIT License | 6 votes |
/** * Creates a new JwtAuthorizationRequest using default configuration and params. */ private JwtAuthorizationRequest createJwtRequest(String keyStoreFile, String keyStoreSecret, String dnName, String userId, String keyId, SignatureAlgorithm signatureAlgorithm) throws Exception { OxAuthCryptoProvider cryptoProvider = new OxAuthCryptoProvider(keyStoreFile, keyStoreSecret, dnName); String clientId = registerResponse.getClientId(); int now = (int)(System.currentTimeMillis() / 1000); JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest( null, signatureAlgorithm, cryptoProvider); jwtAuthorizationRequest.setClientNotificationToken("notification-token-123"); jwtAuthorizationRequest.setAud(issuer); jwtAuthorizationRequest.setLoginHint(userId); jwtAuthorizationRequest.setNbf(now); jwtAuthorizationRequest.setScopes(Collections.singletonList("openid")); jwtAuthorizationRequest.setIss(clientId); jwtAuthorizationRequest.setBindingMessage("1234"); jwtAuthorizationRequest.setExp((int)(DateUtils.addMinutes(new Date(), 5).getTime() / 1000)); jwtAuthorizationRequest.setIat(now); jwtAuthorizationRequest.setJti(UUID.randomUUID().toString()); jwtAuthorizationRequest.setKeyId(keyId); return jwtAuthorizationRequest; }
Example #2
Source File: KafkaMessageDistributionBolt.java From eagle with Apache License 2.0 | 6 votes |
@Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { String site = config.getString("dataSourceConfig.site"); String topic = config.getString("dataSourceConfig.topic"); this.baseMetricDimension = new HashMap<>(); this.baseMetricDimension.put("site", site); this.baseMetricDimension.put("topic", topic); registry = new MetricRegistry(); this.granularity = DEFAULT_METRIC_GRANULARITY; if (config.hasPath("dataSourceConfig.kafkaDistributionDataIntervalMin")) { this.granularity = config.getInt("dataSourceConfig.kafkaDistributionDataIntervalMin") * DateUtils.MILLIS_PER_MINUTE; } String host = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.HOST); int port = config.getInt(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PORT); String username = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.USERNAME); String password = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PASSWORD); listener = new EagleServiceReporterMetricListener(host, port, username, password); }
Example #3
Source File: MarketDataServiceImpl.java From AlgoTrader with GNU General Public License v2.0 | 6 votes |
protected void handlePersistTick(Tick tick) throws IOException { Security security = tick.getSecurity(); // persist ticks only between marketOpen & close if (DateUtil.compareToTime(security.getSecurityFamily().getMarketOpen()) >= 0 && DateUtil.compareToTime(security.getSecurityFamily().getMarketClose()) <= 0) { // get the current Date rounded to MINUTES Date date = DateUtils.round(DateUtil.getCurrentEPTime(), Calendar.MINUTE); tick.setDateTime(date); // write the tick to file CsvTickWriter csvWriter = this.csvWriters.get(security); if (csvWriter == null) { csvWriter = new CsvTickWriter(security.getIsin()); this.csvWriters.put(security, csvWriter); } csvWriter.write(tick); // write the tick to the DB (even if not valid) getTickDao().create(tick); } }
Example #4
Source File: LocalDocumentService.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void deleteBackupFilesOlderThen(File backupDir, int days){ try { if (backupDir.isDirectory()) { Collection<File> filesToDelete = FileUtils.listFiles(backupDir, new AgeFileFilter(DateUtils.addDays(new Date(), days * -1)), TrueFileFilter.TRUE); for (File file : filesToDelete) { boolean success = FileUtils.deleteQuietly(file); if (!success) { LoggerFactory.getLogger(getClass()) .warn("Cannot delete old backup file at: " + file.getAbsolutePath()); } } } } catch (Exception e) { LoggerFactory.getLogger(getClass()).warn("Cannot delete old backup files.", e); } }
Example #5
Source File: BaseQueryMetricHandler.java From datawave with Apache License 2.0 | 6 votes |
public QueryMetricsSummaryResponse processQueryMetricsSummary(List<T> queryMetrics) throws IOException { QueryMetricsSummaryResponse summary = new QueryMetricsSummaryResponse(); Date now = new Date(); Date hour1 = DateUtils.addHours(now, -1); Date hour6 = DateUtils.addHours(now, -6); Date hour12 = DateUtils.addHours(now, -12); Date day1 = DateUtils.addDays(now, -1); Date day7 = DateUtils.addDays(now, -7); Date day30 = DateUtils.addDays(now, -30); Date day60 = DateUtils.addDays(now, -60); Date day90 = DateUtils.addDays(now, -90); for (T metric : queryMetrics) { try { binSummary(metric, summary, hour1, hour6, hour12, day1, day7, day30, day60, day90); } catch (Exception e1) { log.error(e1.getMessage()); } } return summary; }
Example #6
Source File: AccountRule.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * This method checks to see if the account expiration date is today's date or earlier * * @param newAccount * @return fails if the expiration date is null or after today's date */ protected boolean checkAccountExpirationDateValidTodayOrEarlier(Account newAccount) { // get today's date, with no time component Date todaysDate = new Date(getDateTimeService().getCurrentDate().getTime()); todaysDate.setTime(DateUtils.truncate(todaysDate, Calendar.DAY_OF_MONTH).getTime()); // TODO: convert this to using Wes' Kuali KfsDateUtils once we're using Date's instead of Timestamp // get the expiration date, if any Date expirationDate = newAccount.getAccountExpirationDate(); if (ObjectUtils.isNull(expirationDate)) { putFieldError("accountExpirationDate", KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID); return false; } // when closing an account, the account expiration date must be the current date or earlier expirationDate.setTime(DateUtils.truncate(expirationDate, Calendar.DAY_OF_MONTH).getTime()); if (expirationDate.after(todaysDate)) { putFieldError("accountExpirationDate", KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ACCT_CANNOT_BE_CLOSED_EXP_DATE_INVALID); return false; } return true; }
Example #7
Source File: RetirementInfoServiceTest.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
private AssetRetirementGlobalDetail createRetirementDetail(String docNumber, int daysToAdd, String docStatus) { AssetRetirementGlobalDetail globalDetail = new AssetRetirementGlobalDetail(); globalDetail.setDocumentNumber(docNumber); AssetRetirementGlobal retirementGlobal = new AssetRetirementGlobal() { @Override public void refreshReferenceObject(String referenceObjectName) { } }; retirementGlobal.setRetirementDate(new java.sql.Date(DateUtils.addDays(dateTimeService.getCurrentDate(), daysToAdd).getTime())); FinancialSystemDocumentHeader header = new FinancialSystemDocumentHeader(); header.setFinancialDocumentStatusCode(docStatus); retirementGlobal.setDocumentHeader(header); globalDetail.setAssetRetirementGlobal(retirementGlobal); return globalDetail; }
Example #8
Source File: SendMessageTask.java From qmq with Apache License 2.0 | 6 votes |
@Override public Void call() { LOG.info("{} start...", dataSourceInfo.getUrl()); stop = false; String name = Thread.currentThread().getName(); try { Thread.currentThread().setName(dataSourceInfo.getUrl()); long begin = System.currentTimeMillis(); while ((!isStop() && !timeout(begin))) { Date since = DateUtils.addSeconds(new Date(), -DEFAULT_TIME_INTEL); List<MsgQueue> errorMessages = messageClientStore.findErrorMsg(this.dataSource, since); if (errorMessages == null || errorMessages.isEmpty()) { break; } logRemainMsg(errorMessages); processErrorMessages(errorMessages, since); } } catch (Exception e) { throw new RuntimeException("process message error, url: " + dataSourceInfo.getUrl(), e); } finally { stop = true; Thread.currentThread().setName(name); LOG.info("{} finish", dataSourceInfo.getUrl()); } return null; }
Example #9
Source File: DateTimeUtils.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
/** * Converts the time (hour.minute) to a calendar object. */ public static Calendar timeToCalendar(Calendar calendar, double time) { if (time < 0.0) { return null; } Calendar cal = (Calendar) calendar.clone(); int hour = 0; int minute = 0; if (time == 24.0) { cal.add(Calendar.DAY_OF_MONTH, 1); } else { hour = (int) time; minute = (int) ((time * 100) - (hour * 100)); } cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.MINUTE, minute); return DateUtils.truncate(cal, Calendar.MINUTE); }
Example #10
Source File: ServiceAuditDAOImpl.java From eagle with Apache License 2.0 | 6 votes |
@Override public List<GenericAuditEntity> findUserServiceAuditByAction(String userID, String action) throws Exception { try { IEagleServiceClient client = new EagleServiceClientImpl(connector); String query = AuditConstants.AUDIT_SERVICE_ENDPOINT + "[@userID=\"" + userID + "\" AND @actionTaken=\"" + action + "\"]{*}"; GenericServiceAPIResponseEntity<GenericAuditEntity> response = client.search().startTime(0).endTime(10 * DateUtils.MILLIS_PER_DAY).pageSize(Integer.MAX_VALUE).query(query).send(); client.close(); if (response.getException() != null) { throw new Exception("Exception in querying eagle service: " + response.getException()); } return response.getObj(); } catch (Exception exception) { LOG.error("Exception in retrieving audit entry: " + exception); throw new IllegalStateException(exception); } }
Example #11
Source File: RecipientRepositoryTest.java From piggymetrics with MIT License | 6 votes |
@Test public void shouldNotFindReadyForRemindWhenNotificationIsNotActive() { NotificationSettings remind = new NotificationSettings(); remind.setActive(false); remind.setFrequency(Frequency.WEEKLY); remind.setLastNotified(DateUtils.addDays(new Date(), -30)); Recipient recipient = new Recipient(); recipient.setAccountName("test"); recipient.setEmail("[email protected]"); recipient.setScheduledNotifications(ImmutableMap.of( NotificationType.REMIND, remind )); repository.save(recipient); List<Recipient> found = repository.findReadyForRemind(); assertTrue(found.isEmpty()); }
Example #12
Source File: RecipientRepositoryTest.java From piggymetrics with MIT License | 6 votes |
@Test public void shouldNotFindReadyForBackupWhenFrequencyIsQuaterly() { NotificationSettings remind = new NotificationSettings(); remind.setActive(true); remind.setFrequency(Frequency.QUARTERLY); remind.setLastNotified(DateUtils.addDays(new Date(), -91)); Recipient recipient = new Recipient(); recipient.setAccountName("test"); recipient.setEmail("[email protected]"); recipient.setScheduledNotifications(ImmutableMap.of( NotificationType.BACKUP, remind )); repository.save(recipient); List<Recipient> found = repository.findReadyForBackup(); assertFalse(found.isEmpty()); }
Example #13
Source File: DashboardController.java From cloud-portal with MIT License | 6 votes |
private void addProvisioningHistoryToMap(ProvisionLog provisionLog, Map<Long, Integer> provisioningHistoryMap) { Date date = provisionLog.getDate(); if (date.after(this.dateBefore)) { Date calculatedDate = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); // NOSONAR long timeInMillis = calculatedDate.getTime(); Integer counter = provisioningHistoryMap.get(timeInMillis); if (counter == null) { counter = 0; } counter = counter + 1; provisioningHistoryMap.put(timeInMillis, counter); } }
Example #14
Source File: RMContainerImpl.java From hadoop with Apache License 2.0 | 6 votes |
private static void updateAttemptMetrics(RMContainerImpl container) { // If this is a preempted container, update preemption metrics Resource resource = container.getContainer().getResource(); RMAppAttempt rmAttempt = container.rmContext.getRMApps() .get(container.getApplicationAttemptId().getApplicationId()) .getCurrentAppAttempt(); if (ContainerExitStatus.PREEMPTED == container.finishedStatus .getExitStatus()) { rmAttempt.getRMAppAttemptMetrics().updatePreemptionInfo(resource, container); } if (rmAttempt != null) { long usedMillis = container.finishTime - container.creationTime; long memorySeconds = resource.getMemory() * usedMillis / DateUtils.MILLIS_PER_SECOND; long vcoreSeconds = resource.getVirtualCores() * usedMillis / DateUtils.MILLIS_PER_SECOND; long gcoreSeconds = resource.getGpuCores() * usedMillis / DateUtils.MILLIS_PER_SECOND; rmAttempt.getRMAppAttemptMetrics() .updateAggregateAppResourceUsage(memorySeconds,vcoreSeconds, gcoreSeconds); } }
Example #15
Source File: SchedulerApplicationAttempt.java From hadoop with Apache License 2.0 | 6 votes |
synchronized AggregateAppResourceUsage getRunningAggregateAppResourceUsage() { long currentTimeMillis = System.currentTimeMillis(); // Don't walk the whole container list if the resources were computed // recently. if ((currentTimeMillis - lastMemoryAggregateAllocationUpdateTime) > MEM_AGGREGATE_ALLOCATION_CACHE_MSECS) { long memorySeconds = 0; long vcoreSeconds = 0; long gcoreSeconds = 0; for (RMContainer rmContainer : this.liveContainers.values()) { long usedMillis = currentTimeMillis - rmContainer.getCreationTime(); Resource resource = rmContainer.getContainer().getResource(); memorySeconds += resource.getMemory() * usedMillis / DateUtils.MILLIS_PER_SECOND; vcoreSeconds += resource.getVirtualCores() * usedMillis / DateUtils.MILLIS_PER_SECOND; gcoreSeconds += resource.getGpuCores() * usedMillis / DateUtils.MILLIS_PER_SECOND; } lastMemoryAggregateAllocationUpdateTime = currentTimeMillis; lastMemorySeconds = memorySeconds; lastVcoreSeconds = vcoreSeconds; lastGcoreSeconds = gcoreSeconds; } return new AggregateAppResourceUsage(lastMemorySeconds, lastVcoreSeconds, lastGcoreSeconds); }
Example #16
Source File: HighchartPoint.java From cachecloud with Apache License 2.0 | 6 votes |
public static HighchartPoint getFromAppCommandStats(AppCommandStats appCommandStats, Date currentDate, int diffDays) throws ParseException { Date collectDate = getDateTime(appCommandStats.getCollectTime()); if (!DateUtils.isSameDay(currentDate, collectDate)) { return null; } //显示用的时间 String date = null; try { date = DateUtil.formatDate(collectDate, "yyyy-MM-dd HH:mm"); } catch (Exception e) { date = DateUtil.formatDate(collectDate, "yyyy-MM-dd HH"); } // y坐标 long commandCount = appCommandStats.getCommandCount(); // x坐标 //为了显示在一个时间范围内 if (diffDays > 0) { collectDate = DateUtils.addDays(collectDate, diffDays); } return new HighchartPoint(collectDate.getTime(), commandCount, date); }
Example #17
Source File: DateIndexDataTypeHandler.java From datawave with Apache License 2.0 | 5 votes |
/** * Construct a date index entry * * @param shardId * @param dataType * @param type * @param dateField * @param dateValue * @param visibility * @return The key and value */ public KeyValue getDateIndexEntry(String shardId, String dataType, String type, String dateField, String dateValue, ColumnVisibility visibility) { Date date = null; try { // get the date to be indexed date = dateNormalizer.denormalize(dateValue); } catch (Exception e) { log.error("Failed to normalize date value (skipping): " + dateValue, e); return null; } // set the time to 00:00:00 (for key timestamp) date = DateUtils.truncate(date, Calendar.DATE); // format the date and the shardId date as yyyyMMdd String rowDate = DateIndexUtil.format(date); String shardDate = ShardIdFactory.getDateString(shardId); ColumnVisibility biased = new ColumnVisibility(flatten(visibility)); // The row is the date plus the shard partition String row = rowDate + '_' + getDateIndexShardPartition(rowDate, type, shardDate, dataType, dateField, new String(biased.getExpression())); // the colf is the type (e.g. LOAD or ACTIVITY) // the colq is the event date yyyyMMdd \0 the datatype \0 the field name String colq = shardDate + '\0' + dataType + '\0' + dateField; // the value is a bitset denoting the shard Value shardList = createDateIndexValue(ShardIdFactory.getShard(shardId)); // create the key Key key = new Key(row, type, colq, biased, date.getTime()); if (log.isTraceEnabled()) { log.trace("Dateate index key: " + key + " for shardId " + shardId); } return new KeyValue(key, shardList); }
Example #18
Source File: DashboardController.java From cloud-portal with MIT License | 5 votes |
private void fillUpProvisioningHistory(Map<Long, Integer> provisioningHistoryMap) { for (int i = 0; i <= DAYS_BEFORE; i++) { Date date = getDate(i); long timeInMillis = DateUtils.truncate(date, Calendar.DAY_OF_MONTH).getTime(); // NOSONAR if (!provisioningHistoryMap.containsKey(timeInMillis)) { provisioningHistoryMap.put(timeInMillis, 0); } } }
Example #19
Source File: PriorYearAccount.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * This method determines whether the account is expired or not. Note that if Expiration Date is the same date as testDate, then * this will return false. It will only return true if the account expiration date is one day earlier than testDate or earlier. * Note that this logic ignores all time components when doing the comparison. It only does the before/after comparison based on * date values, not time-values. * * @param testDate - Calendar instance with the date to test the Account's Expiration Date against. This is most commonly set to * today's date. * @return true or false based on the logic outlined above */ @Override public boolean isExpired(Calendar testDate) { if (LOG.isDebugEnabled()) { LOG.debug("entering isExpired(" + testDate + ")"); } // dont even bother trying to test if the accountExpirationDate is null if (this.accountExpirationDate == null) { return false; } // remove any time-components from the testDate testDate = DateUtils.truncate(testDate, Calendar.DAY_OF_MONTH); // get a calendar reference to the Account Expiration // date, and remove any time components Calendar acctDate = Calendar.getInstance(); acctDate.setTime(this.accountExpirationDate); acctDate = DateUtils.truncate(acctDate, Calendar.DAY_OF_MONTH); // if the Account Expiration Date is before the testDate if (acctDate.before(testDate)) { return true; } else { return false; } }
Example #20
Source File: UserMgmtService.java From symphonyx with Apache License 2.0 | 5 votes |
/** * Resets unverified users. */ @Transactional public void resetUnverifiedUsers() { final Date now = new Date(); final long yesterdayTime = DateUtils.addDays(now, -1).getTime(); final List<Filter> filters = new ArrayList<Filter>(); filters.add(new PropertyFilter(UserExt.USER_STATUS, FilterOperator.EQUAL, UserExt.USER_STATUS_C_NOT_VERIFIED)); filters.add(new PropertyFilter(Keys.OBJECT_ID, FilterOperator.LESS_THAN_OR_EQUAL, yesterdayTime)); filters.add(new PropertyFilter(User.USER_NAME, FilterOperator.NOT_EQUAL, UserExt.NULL_USER_NAME)); final Query query = new Query().setFilter(new CompositeFilter(CompositeFilterOperator.AND, filters)); try { final JSONObject result = userRepository.get(query); final JSONArray users = result.optJSONArray(Keys.RESULTS); for (int i = 0; i < users.length(); i++) { final JSONObject user = users.optJSONObject(i); final String id = user.optString(Keys.OBJECT_ID); user.put(User.USER_NAME, UserExt.NULL_USER_NAME); userRepository.update(id, user); LOGGER.log(Level.INFO, "Reset unverified user [email=" + user.optString(User.USER_EMAIL)); } } catch (final RepositoryException e) { LOGGER.log(Level.ERROR, "Reset unverified users failed", e); } }
Example #21
Source File: TravelAuthorizationServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
private Date getTripEndDate(Timestamp tripEndDate) { Date tripEnd = null; Integer days = getDuplicateTripDateRangeDays(); try { tripEnd = dateTimeService.convertToSqlDate(dateTimeService.toDateString((DateUtils.addDays(tripEndDate, days )))); } catch (ParseException pe) { LOG.error("Exception while parsing trip end date" + pe); } return tripEnd; }
Example #22
Source File: AppClientDataShowController.java From cachecloud with Apache License 2.0 | 5 votes |
/** * 异常查询日期格式 */ private TimeBetween fillWithClientExceptionTime(HttpServletRequest request, Model model) throws ParseException { final String exceptionDateFormat = "yyyy-MM-dd"; String exceptionStartDateParam = request.getParameter("exceptionStartDate"); String exceptionEndDateParam = request.getParameter("exceptionEndDate"); Date startDate; Date endDate; if (StringUtils.isBlank(exceptionStartDateParam) || StringUtils.isBlank(exceptionEndDateParam)) { // 如果为空默认取昨天和今天 SimpleDateFormat sdf = new SimpleDateFormat(exceptionDateFormat); startDate = sdf.parse(sdf.format(new Date())); endDate = DateUtils.addDays(startDate, 1); exceptionStartDateParam = DateUtil.formatDate(startDate, exceptionDateFormat); exceptionEndDateParam = DateUtil.formatDate(endDate, exceptionDateFormat); } else { endDate = DateUtil.parse(exceptionEndDateParam, exceptionDateFormat); startDate = DateUtil.parse(exceptionStartDateParam, exceptionDateFormat); //限制不能超过7天 if (endDate.getTime() - startDate.getTime() > TimeUnit.DAYS.toMillis(7)) { startDate = DateUtils.addDays(endDate, -7); } } // 前端需要 model.addAttribute("exceptionStartDate", exceptionStartDateParam); model.addAttribute("exceptionEndDate", exceptionEndDateParam); // 查询后台需要 long startTime = NumberUtils.toLong(DateUtil.formatDate(startDate, COLLECT_TIME_FORMAT)); long endTime = NumberUtils.toLong(DateUtil.formatDate(endDate, COLLECT_TIME_FORMAT)); return new TimeBetween(startTime, endTime, startDate, endDate); }
Example #23
Source File: SepShowcases.java From sep4j with Apache License 2.0 | 5 votes |
/** * if the cell is of String type * * @param birthDayString * @throws ParseException */ public void setBirthDay(String birthDayString) throws ParseException { if (birthDayString == null) { return; } birthDay = DateUtils.parseDate(birthDayString, new String[] { "yyyy-MM-dd" }); }
Example #24
Source File: PerDiemLoadServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * This method... * @param perDiem * @return */ protected Date buildDate(PerDiemForLoad perDiem, String seasonDateAsString) { int effectiveYear = this.getEffectiveYear(perDiem); Date effectiveDate = perDiem.getEffectiveFromDate(); Date seasonDate = this.getDateFromString(seasonDateAsString, effectiveYear); int difference = this.getDateTimeService().dateDiff(effectiveDate, seasonDate, true); if(difference <= 0){ DateUtils.addYears(seasonDate, 1); } return seasonDate; }
Example #25
Source File: DefaultDeduplicator.java From Eagle with Apache License 2.0 | 5 votes |
public AlertDeduplicationStatus checkDedup(EntityTagsUniq key){ long current = key.timestamp; if(!entites.containsKey(key)){ entites.put(key, current); return AlertDeduplicationStatus.NEW; } long last = entites.get(key); if(current - last >= dedupIntervalMin * DateUtils.MILLIS_PER_MINUTE){ entites.put(key, current); return AlertDeduplicationStatus.DUPLICATED; } return AlertDeduplicationStatus.IGNORED; }
Example #26
Source File: RdsBinlogOpenApiTest.java From canal with Apache License 2.0 | 5 votes |
@Test public void testSimple() throws Throwable { Date startTime = DateUtils.parseDate("2018-08-10 12:00:00", new String[] { "yyyy-MM-dd HH:mm:ss" }); Date endTime = DateUtils.parseDate("2018-08-11 12:00:00", new String[] { "yyyy-MM-dd HH:mm:ss" }); String url = "https://rds.aliyuncs.com/"; String ak = ""; String sk = ""; String dbInstanceId = ""; RdsBackupPolicy backupPolicy = RdsBinlogOpenApi.queryBinlogBackupPolicy(url, ak, sk, dbInstanceId); System.out.println(backupPolicy); List<BinlogFile> binlogFiles = RdsBinlogOpenApi.listBinlogFiles(url, ak, sk, dbInstanceId, startTime, endTime); System.out.println(binlogFiles); }
Example #27
Source File: ModeUtils.java From DataLink with Apache License 2.0 | 5 votes |
public static String tryBuildYearlyPattern(String value) { String valueSuffix = StringUtils.substring(value, value.length() - 4); try { DateUtils.parseDate(valueSuffix, new String[]{"yyyy"}); return StringUtils.substring(value, 0, value.length() - 4) + YEAR_SUFFIX; } catch (ParseException e) { } return value; }
Example #28
Source File: UpcomingMilestoneNotificationServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * @see org.kuali.kfs.module.ar.batch.service.UpcomingMilestoneNotificationService#sendNotificationsForMilestones() */ @Override @Transactional public void sendNotificationsForMilestones() { int limitDays = new Integer(parameterService.getParameterValueAsString(UpcomingMilestoneNotificationStep.class, ArConstants.CHECK_LIMIT_DAYS)); final Date expectedCompletionLimitDate = DateUtils.addDays(dateTimeService.getCurrentDate(), limitDays); List<Milestone> milestones = (List<Milestone>) milestoneDao.getMilestonesForNotification(expectedCompletionLimitDate); if (CollectionUtils.isNotEmpty(milestones)) { sendAdviceNotifications(milestones, milestones.get(0).getAward()); } }
Example #29
Source File: ReflectUtil.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
/** * 从jar包中查找指定接口的一个实现类 非反射 * * @param interfaceClass * @param jarPath * @return * @throws Exception */ public static Class findImplementFromJar(Class interfaceClass, URL jarPath) throws Exception { URL url = new URL("jar:" + jarPath.toString() + "!/"); JarURLConnection jarConnection = (JarURLConnection) url.openConnection(); JarFile jarFile = jarConnection.getJarFile(); Enumeration<JarEntry> je = jarFile.entries(); boolean flag = false; while (je.hasMoreElements()) { JarEntry e = je.nextElement(); String n = e.getName(); FileTime ft = e.getLastModifiedTime(); if (DateUtils.addDays(new Date(), -100).getTime() - ft.toMillis() > 0) { LOGGER.info("jar文件时间超过100天,跳过查找实现类:" + jarFile.getName().substring(jarFile.getName().lastIndexOf("\\")) + ft.toString()); return null; } else { if (!flag) { flag = true; LOGGER.info("在" + jarFile.getName().substring(jarFile.getName().lastIndexOf("\\")) + "中查找实现类"); } } if (n.endsWith(".class")) { n = n.substring(0, n.length() - 6); n = n.replace('/', '.'); Class currentClass = ClassLoader.getSystemClassLoader().loadClass(n); if (interfaceClass.isAssignableFrom(currentClass) && !n.equals(interfaceClass.getName())) { return currentClass; } } } return null; }
Example #30
Source File: BatchExtractServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * Computes the last run time stamp, if null then it gives yesterday * * @return Last run time stamp */ protected Timestamp getCabLastRunTimestamp() { Timestamp lastRunTime; String lastRunTS = parameterService.getParameterValueAsString(KfsParameterConstants.CAPITAL_ASSET_BUILDER_BATCH.class, CabConstants.Parameters.LAST_EXTRACT_TIME); java.util.Date yesterday = DateUtils.add(dateTimeService.getCurrentDate(), Calendar.DAY_OF_MONTH, -1); try { lastRunTime = lastRunTS == null ? new Timestamp(yesterday.getTime()) : new Timestamp(DateUtils.parseDate(lastRunTS, new String[] { CabConstants.DateFormats.MONTH_DAY_YEAR + " " + CabConstants.DateFormats.MILITARY_TIME }).getTime()); } catch (ParseException e) { throw new RuntimeException(e); } return lastRunTime; }