Java Code Examples for org.apache.commons.lang3.time.DateUtils#MILLIS_PER_MINUTE
The following examples show how to use
org.apache.commons.lang3.time.DateUtils#MILLIS_PER_MINUTE .
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: AbstractHdfsAuditLogApplication.java From eagle with Apache License 2.0 | 6 votes |
public static PartitionStrategy createStrategy(Config config) { // TODO: Refactor configuration structure to avoid repeated config processing configure ~ hao String host = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.HOST); Integer 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); String topic = config.getString("dataSourceConfig.topic"); DataDistributionDao dao = new DataDistributionDaoImpl(host, port, username, password, topic); PartitionAlgorithm algorithm = new GreedyPartitionAlgorithm(); String key1 = EagleConfigConstants.EAGLE_PROPS + ".partitionRefreshIntervalInMin"; Integer partitionRefreshIntervalInMin = config.hasPath(key1) ? config.getInt(key1) : 60; String key2 = EagleConfigConstants.EAGLE_PROPS + ".kafkaStatisticRangeInMin"; Integer kafkaStatisticRangeInMin = config.hasPath(key2) ? config.getInt(key2) : 60; PartitionStrategy strategy = new PartitionStrategyImpl(dao, algorithm, partitionRefreshIntervalInMin * DateUtils.MILLIS_PER_MINUTE, kafkaStatisticRangeInMin * DateUtils.MILLIS_PER_MINUTE); return strategy; }
Example 2
Source File: PortalMapper.java From KaellyBot with GNU General Public License v3.0 | 5 votes |
private static String getLabelTimeAgo(Instant time, Language lg){ long timeLeft = Math.abs(Duration.between(time, Instant.now()).toMillis()); if (timeLeft < DateUtils.MILLIS_PER_MINUTE) return Translator.getLabel(lg, "portal.date.now"); else if (timeLeft < DateUtils.MILLIS_PER_HOUR) return Translator.getLabel(lg, "portal.date.minutes_ago") .replace("{time}", String.valueOf(timeLeft / DateUtils.MILLIS_PER_MINUTE)); else return Translator.getLabel(lg, "portal.date.hours_ago") .replace("{time}", String.valueOf(timeLeft / DateUtils.MILLIS_PER_HOUR)); }
Example 3
Source File: FarmInformation.java From dsworkbench with Apache License 2.0 | 5 votes |
private void guessResourceBuildings(FightReport pReport) { if (pReport == null || pReport.getHaul() == null) { // no info return; } // only use if last report is not too old....!! -> send time - 30min !? // and if last attack returned empty long send = pReport.getTimestamp() - DSCalculator.calculateMoveTimeInMillis(pReport.getSourceVillage(), pReport.getTargetVillage(), pReport.getAttackers().getSpeed()); if (resourcesFoundInLastReport || lastReport == -1 || lastReport < send - 200 * DateUtils.MILLIS_PER_MINUTE || lastReport == pReport.getTimestamp()) { // ignore this report return; } int wood = pReport.getHaul()[0]; int clay = pReport.getHaul()[1]; int iron = pReport.getHaul()[2]; double dt = (pReport.getTimestamp() - lastReport) / (double) DateUtils.MILLIS_PER_HOUR; int woodBuildingLevel = DSCalculator.calculateEstimatedResourceBuildingLevel(wood, dt); int clayBuildingLevel = DSCalculator.calculateEstimatedResourceBuildingLevel(clay, dt); int ironBuildingLevel = DSCalculator.calculateEstimatedResourceBuildingLevel(iron, dt); setBuilding("wood", Math.max(getBuilding("wood"), woodBuildingLevel)); setBuilding("stone", Math.max(getBuilding("stone"), clayBuildingLevel)); setBuilding("iron", Math.max(getBuilding("iron"), ironBuildingLevel)); }
Example 4
Source File: DefenseInformation.java From dsworkbench with Apache License 2.0 | 5 votes |
public boolean addSupport(final Village pSource, UnitHolder pUnit, boolean pPrimary, boolean pMultiUse) { long runtime = DSCalculator.calculateMoveTimeInMillis(pSource, target, pUnit.getSpeed()); boolean allowed = false; if (getFirstAttack().getTime() - runtime > System.currentTimeMillis() + DateUtils.MILLIS_PER_MINUTE) { //high priority allowed = true; } else if (getLastAttack().getTime() - runtime > System.currentTimeMillis() + DateUtils.MILLIS_PER_MINUTE) { //low priority allowed = !pPrimary; } else {// if (getLastAttack().getTime() - runtime < System.currentTimeMillis() - DateUtils.MILLIS_PER_MINUTE) { //impossible } if (allowed) { Object result = CollectionUtils.find(defenses, new Predicate() { @Override public boolean evaluate(Object o) { return ((Defense) o).getSupporter().equals(pSource); } }); if (result == null || pMultiUse) { defenses.add(new Defense(this, pSource, pUnit)); return true; } } return false; }
Example 5
Source File: RetimerCalculationPanel.java From dsworkbench with Apache License 2.0 | 5 votes |
private List<Attack> getRetimesForVillage(Attack pAttack, VillageTroopsHolder pHolder) { List<Attack> results = new LinkedList<>(); Village target = pAttack.getSource(); Village source = pHolder.getVillage(); long returnTime = pAttack.getReturnTime().getTime(); List<UnitHolder> units = pHolder.getTroops().getContainedUnits(null); Collections.sort(units, UnitHolder.RUNTIME_COMPARATOR); for (int i = units.size() - 1; i >= 0; i--) { UnitHolder unit = units.get(i); if (unit.isRetimeUnit()) { notifyStatusUpdate(" - Teste Einheit '" + unit.getName() + "'"); long sendTime = returnTime - DSCalculator.calculateMoveTimeInMillis(source, target, unit.getSpeed()); if (sendTime > System.currentTimeMillis() + DateUtils.MILLIS_PER_MINUTE) { boolean allowFromSame = true; if (source.getId() == pAttack.getTarget().getId()) { if (sendTime < pAttack.getArriveTime().getTime() + DateUtils.MILLIS_PER_MINUTE) { notifyStatusUpdate(" - Angriffsziel und Retime-Herkunft identisch, Abschickzeit zu nah an Ankunft"); allowFromSame = false; } } if (allowFromSame) { notifyStatusUpdate(" - Einheit für Retime geeignet"); Attack a = new Attack(); a.setSource(source); a.setTarget(target); a.setUnit(unit); a.setSendTime(new Date(sendTime)); a.setType(Attack.CLEAN_TYPE); a.setTroopsByType(); results.add(a); } } } } return results; }
Example 6
Source File: DateTimeType.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public int getTzHour() { return (int) (getTimeZone().getRawOffset() / DateUtils.MILLIS_PER_MINUTE) / 60; }
Example 7
Source File: DateTimeType.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public int getTzMin() { return (int) (getTimeZone().getRawOffset() / DateUtils.MILLIS_PER_MINUTE) % 60; }
Example 8
Source File: DateTimeType.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public int getTzHour() { return (int) (getTimeZone().getRawOffset() / DateUtils.MILLIS_PER_MINUTE) / 60; }
Example 9
Source File: DateTimeType.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public int getTzMin() { return (int) (getTimeZone().getRawOffset() / DateUtils.MILLIS_PER_MINUTE) % 60; }
Example 10
Source File: DateTimeType.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public int getTzHour() { return (int) (getTimeZone().getRawOffset() / DateUtils.MILLIS_PER_MINUTE) / 60; }
Example 11
Source File: DateTimeType.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public int getTzMin() { return (int) (getTimeZone().getRawOffset() / DateUtils.MILLIS_PER_MINUTE) % 60; }
Example 12
Source File: DateTimeType.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public int getTzHour() { return (int) (getTimeZone().getRawOffset() / DateUtils.MILLIS_PER_MINUTE) / 60; }
Example 13
Source File: DateTimeType.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public int getTzMin() { return (int) (getTimeZone().getRawOffset() / DateUtils.MILLIS_PER_MINUTE) % 60; }
Example 14
Source File: DateTimeType.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public int getTzHour() { return (int) (getTimeZone().getRawOffset() / DateUtils.MILLIS_PER_MINUTE) / 60; }
Example 15
Source File: DateTimeType.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public int getTzMin() { return (int) (getTimeZone().getRawOffset() / DateUtils.MILLIS_PER_MINUTE) % 60; }