List of usage examples for org.joda.time DateTime plusMinutes
public DateTime plusMinutes(int minutes)
From source file:org.apache.beam.sdk.extensions.sql.impl.interpreter.operator.date.BeamSqlDatetimePlusExpression.java
License:Apache License
private DateTime addInterval(DateTime dateTime, SqlTypeName intervalType, int numberOfIntervals) { switch (intervalType) { case INTERVAL_SECOND: return dateTime.plusSeconds(numberOfIntervals); case INTERVAL_MINUTE: return dateTime.plusMinutes(numberOfIntervals); case INTERVAL_HOUR: return dateTime.plusHours(numberOfIntervals); case INTERVAL_DAY: return dateTime.plusDays(numberOfIntervals); case INTERVAL_MONTH: return dateTime.plusMonths(numberOfIntervals); case INTERVAL_YEAR: return dateTime.plusYears(numberOfIntervals); default:/*from w ww. j av a2s . c om*/ throw new IllegalArgumentException("Adding " + intervalType.getName() + " to date is not supported"); } }
From source file:org.apache.falcon.regression.core.util.TimeUtil.java
License:Apache License
public static List<String> getMinuteDatesOnEitherSide(int interval, int minuteSkip) { DateTime today = new DateTime(DateTimeZone.UTC); LOGGER.info("today is: " + today.toString()); return getMinuteDatesOnEitherSide(today.minusMinutes(interval), today.plusMinutes(interval), minuteSkip); }
From source file:org.apache.falcon.regression.core.util.TimeUtil.java
License:Apache License
public static List<String> getMinuteDatesOnEitherSide(DateTime startDate, DateTime endDate, int minuteSkip, DateTimeFormatter formatter) { LOGGER.info("generating data between " + formatter.print(startDate) + " and " + formatter.print(endDate)); if (minuteSkip == 0) { minuteSkip = 1;/*from www . ja va2s.c o m*/ } List<String> dates = new ArrayList<>(); while (!startDate.isAfter(endDate)) { dates.add(formatter.print(startDate)); startDate = startDate.plusMinutes(minuteSkip); } return dates; }
From source file:org.apache.falcon.regression.core.util.TimeUtil.java
License:Apache License
public static String getTimeWrtSystemTime(int minutes) { DateTime jodaTime = new DateTime(DateTimeZone.UTC); if (minutes > 0) { jodaTime = jodaTime.plusMinutes(minutes); } else {// ww w . j av a2 s.com jodaTime = jodaTime.minusMinutes(-1 * minutes); } DateTimeFormatter fmt = OozieUtil.getOozieDateTimeFormatter(); DateTimeZone tz = DateTimeZone.getDefault(); return fmt.print(tz.convertLocalToUTC(jodaTime.getMillis(), false)); }
From source file:org.apache.falcon.regression.core.util.TimeUtil.java
License:Apache License
public static String addMinsToTime(String time, int minutes) { DateTimeFormatter fmt = OozieUtil.getOozieDateTimeFormatter(); DateTime jodaTime = fmt.parseDateTime(time); jodaTime = jodaTime.plusMinutes(minutes); return fmt.print(jodaTime); }
From source file:org.apache.pig.pen.AugmentBaseDataVisitor.java
License:Apache License
Object GetLargerValue(Object v) { byte type = DataType.findType(v); if (type == DataType.BAG || type == DataType.TUPLE || type == DataType.MAP) return null; switch (type) { case DataType.CHARARRAY: return (String) v + "0"; case DataType.BYTEARRAY: String str = ((DataByteArray) v).toString(); str = str + "0"; return new DataByteArray(str); case DataType.INTEGER: return Integer.valueOf((Integer) v + 1); case DataType.LONG: return Long.valueOf((Long) v + 1); case DataType.FLOAT: return Float.valueOf((Float) v + 1); case DataType.DOUBLE: return Double.valueOf((Double) v + 1); case DataType.BIGINTEGER: return ((BigInteger) v).add(BigInteger.ONE); case DataType.BIGDECIMAL: return ((BigDecimal) v).add(BigDecimal.ONE); case DataType.DATETIME: DateTime dt = (DateTime) v; if (dt.getMillisOfSecond() != 0) { return dt.plusMillis(1); } else if (dt.getSecondOfMinute() != 0) { return dt.plusSeconds(1); } else if (dt.getMinuteOfHour() != 0) { return dt.plusMinutes(1); } else if (dt.getHourOfDay() != 0) { return dt.plusHours(1); } else {/* w w w . j a va2s.co m*/ return dt.plusDays(1); } default: return null; } }
From source file:org.apache.syncope.core.logic.SAML2SPLogic.java
License:Apache License
@PreAuthorize("isAuthenticated() and not(hasRole('" + StandardEntitlement.ANONYMOUS + "'))") public SAML2RequestTO createLogoutRequest(final String accessToken, final String spEntityID) { check();//from w ww. ja va2 s . c o m // 1. fetch the current JWT used for Syncope authentication JwsJwtCompactConsumer consumer = new JwsJwtCompactConsumer(accessToken); if (!consumer.verifySignatureWith(jwsSignatureVerifier)) { throw new IllegalArgumentException("Invalid signature found in Access Token"); } // 2. look for IdP String idpEntityID = (String) consumer.getJwtClaims().getClaim(JWT_CLAIM_IDP_ENTITYID); if (idpEntityID == null) { throw new NotFoundException("No SAML 2.0 IdP information found in the access token"); } SAML2IdPEntity idp = cache.get(idpEntityID); if (idp == null) { throw new NotFoundException("SAML 2.0 IdP '" + idpEntityID + "'"); } if (idp.getSLOLocation(idp.getBindingType()) == null) { throw new IllegalArgumentException("No SingleLogoutService available for " + idp.getId()); } // 3. create LogoutRequest LogoutRequest logoutRequest = new LogoutRequestBuilder().buildObject(); logoutRequest.setID("_" + UUID_GENERATOR.generate().toString()); logoutRequest.setDestination(idp.getSLOLocation(idp.getBindingType()).getLocation()); DateTime now = new DateTime(); logoutRequest.setIssueInstant(now); logoutRequest.setNotOnOrAfter(now.plusMinutes(5)); Issuer issuer = new IssuerBuilder().buildObject(); issuer.setValue(spEntityID); logoutRequest.setIssuer(issuer); NameID nameID = new NameIDBuilder().buildObject(); nameID.setFormat((String) consumer.getJwtClaims().getClaim(JWT_CLAIM_NAMEID_FORMAT)); nameID.setValue((String) consumer.getJwtClaims().getClaim(JWT_CLAIM_NAMEID_VALUE)); logoutRequest.setNameID(nameID); SessionIndex sessionIndex = new SessionIndexBuilder().buildObject(); sessionIndex.setSessionIndex((String) consumer.getJwtClaims().getClaim(JWT_CLAIM_SESSIONINDEX)); logoutRequest.getSessionIndexes().add(sessionIndex); SAML2RequestTO requestTO = new SAML2RequestTO(); requestTO.setIdpServiceAddress(logoutRequest.getDestination()); requestTO.setBindingType(idp.getBindingType()); try { // 3. generate relay state as JWT Map<String, Object> claims = new HashMap<>(); claims.put(JWT_CLAIM_IDP_DEFLATE, idp.getBindingType() == SAML2BindingType.REDIRECT ? true : idp.isUseDeflateEncoding()); Triple<String, String, Date> relayState = accessTokenDataBinder.generateJWT(logoutRequest.getID(), JWT_RELAY_STATE_DURATION, claims); requestTO.setRelayState(relayState.getMiddle()); // 4. sign and encode AuthnRequest switch (idp.getBindingType()) { case REDIRECT: requestTO.setContent(saml2rw.encode(logoutRequest, true)); requestTO.setSignAlg(saml2rw.getSigAlgo()); requestTO.setSignature(saml2rw.sign(requestTO.getContent(), requestTO.getRelayState())); break; case POST: default: saml2rw.sign(logoutRequest); requestTO.setContent(saml2rw.encode(logoutRequest, idp.isUseDeflateEncoding())); } } catch (Exception e) { LOG.error("While generating LogoutRequest", e); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown); sce.getElements().add(e.getMessage()); throw sce; } return requestTO; }
From source file:org.apache.ws.security.saml.ext.builder.SAML1ComponentBuilder.java
License:Apache License
/** * Create a Conditions object/*from ww w . j a v a 2s . c o m*/ * * @param conditionsBean A ConditionsBean object * @return a Conditions object */ @SuppressWarnings("unchecked") public static Conditions createSamlv1Conditions(ConditionsBean conditionsBean) { if (conditionsV1Builder == null) { conditionsV1Builder = (SAMLObjectBuilder<Conditions>) builderFactory .getBuilder(Conditions.DEFAULT_ELEMENT_NAME); } Conditions conditions = conditionsV1Builder.buildObject(); if (conditionsBean == null) { DateTime newNotBefore = new DateTime(); conditions.setNotBefore(newNotBefore); conditions.setNotOnOrAfter(newNotBefore.plusMinutes(5)); return conditions; } int tokenPeriodMinutes = conditionsBean.getTokenPeriodMinutes(); DateTime notBefore = conditionsBean.getNotBefore(); DateTime notAfter = conditionsBean.getNotAfter(); if (notBefore != null && notAfter != null) { if (notBefore.isAfter(notAfter)) { throw new IllegalStateException("The value of notBefore may not be after the value of notAfter"); } conditions.setNotBefore(notBefore); conditions.setNotOnOrAfter(notAfter); } else { DateTime newNotBefore = new DateTime(); conditions.setNotBefore(newNotBefore); if (tokenPeriodMinutes <= 0) { tokenPeriodMinutes = 5; } conditions.setNotOnOrAfter(newNotBefore.plusMinutes(tokenPeriodMinutes)); } if (conditionsBean.getAudienceURI() != null) { AudienceRestrictionCondition audienceRestriction = createSamlv1AudienceRestriction( conditionsBean.getAudienceURI()); conditions.getAudienceRestrictionConditions().add(audienceRestriction); } return conditions; }
From source file:org.apache.ws.security.saml.ext.builder.SAML2ComponentBuilder.java
License:Apache License
/** * Create a Conditions object//from w w w . j a va 2s . com * * @param conditionsBean A ConditionsBean object * @return a Conditions object */ @SuppressWarnings("unchecked") public static Conditions createConditions(ConditionsBean conditionsBean) { if (conditionsBuilder == null) { conditionsBuilder = (SAMLObjectBuilder<Conditions>) builderFactory .getBuilder(Conditions.DEFAULT_ELEMENT_NAME); } Conditions conditions = conditionsBuilder.buildObject(); if (conditionsBean == null) { DateTime newNotBefore = new DateTime(); conditions.setNotBefore(newNotBefore); conditions.setNotOnOrAfter(newNotBefore.plusMinutes(5)); return conditions; } int tokenPeriodMinutes = conditionsBean.getTokenPeriodMinutes(); DateTime notBefore = conditionsBean.getNotBefore(); DateTime notAfter = conditionsBean.getNotAfter(); if (notBefore != null && notAfter != null) { if (notBefore.isAfter(notAfter)) { throw new IllegalStateException("The value of notBefore may not be after the value of notAfter"); } conditions.setNotBefore(notBefore); conditions.setNotOnOrAfter(notAfter); } else { DateTime newNotBefore = new DateTime(); conditions.setNotBefore(newNotBefore); if (tokenPeriodMinutes <= 0) { tokenPeriodMinutes = 5; } conditions.setNotOnOrAfter(newNotBefore.plusMinutes(tokenPeriodMinutes)); } if (conditionsBean.getAudienceURI() != null) { AudienceRestriction audienceRestriction = createAudienceRestriction(conditionsBean.getAudienceURI()); conditions.getAudienceRestrictions().add(audienceRestriction); } return conditions; }
From source file:org.apereo.portal.events.aggr.AggregationInterval.java
License:Apache License
/** * Determine the ending DateTime (exclusive) of an interval based on an instant in time * * @param instant The start of an instant * @return/* w w w . ja va 2 s . co m*/ */ public DateTime determineEnd(DateTime instant) { if (this.dateTimeFieldType != null) { final DateTime start = instant.property(this.dateTimeFieldType).roundFloorCopy(); return start.property(this.dateTimeFieldType).addToCopy(1); } if (this == AggregationInterval.FIVE_MINUTE) { final DateTime start = instant.hourOfDay().roundFloorCopy() .plusMinutes((instant.getMinuteOfHour() / 5) * 5); return start.plusMinutes(5); } throw new IllegalArgumentException( "Cannot compute interval end time for " + this + " please use " + AggregationIntervalHelper.class); }