List of usage examples for org.joda.time DateTime getMillis
public long getMillis()
From source file:ch.icclab.cyclops.util.Time.java
License:Open Source License
public static Long fromNovaTimeToMills(String time) { DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS").withZoneUTC(); DateTime date = format.parseDateTime(time); return date.getMillis(); }
From source file:ch.icclab.cyclops.util.Time.java
License:Open Source License
public static Long fromOpenstackTimeToMills(String time) { DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd' 'HH:mm:ss.SSSSSS").withZoneUTC(); DateTime date = format.parseDateTime(time); return date.getMillis(); }
From source file:ch.opentrainingcenter.model.training.filter.internal.FilterTrainingByDate.java
License:Open Source License
private long round(final Date date, final int hour, final int minute) { final DateTime dtStart = new DateTime(date); final int year = dtStart.getYear(); final int monthOfYear = dtStart.getMonthOfYear(); final int dayOfYear = dtStart.getDayOfMonth(); final DateTime dt = new DateTime(year, monthOfYear, dayOfYear, hour, minute); return dt.getMillis(); }
From source file:ch.simuonline.idh.attribute.resolver.dc.aq.AttributeQueryDataConnector.java
License:Apache License
/** {@inheritDoc} */ @Override//www.ja va 2 s . com @Nonnull protected Map<String, IdPAttribute> doDataConnectorResolve( @Nonnull final AttributeResolutionContext resolutionContext, @Nonnull final AttributeResolverWorkContext workContext) throws ResolutionException { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); final DateTime start = DateTime.now(); log.debug("{} Begin with resolving Attributes, the principal is: {}, Start time of AQ Extension: {}!", getLogPrefix(), resolutionContext.getPrincipal(), start); // get informations about the query target AQTarget queryTarget = targetResolvingStrategy.resolveTargetInformations(resolutionContext); if (queryTarget == null || StringSupport.trimOrNull(queryTarget.getNameID()) == null || (signatureRequired && queryTarget.getCertificate() == null) || StringSupport.trimOrNull(queryTarget.getEntityID()) == null || StringSupport.trimOrNull(queryTarget.getAttributeQueryURL()) == null) { log.warn("{} No working target informations for the attribute query found for principal: {}", getLogPrefix(), resolutionContext.getPrincipal()); return null; } // get the aq context and check if there are attributes to resolve from the metadata of this service provider AttributeQueryContext aqcontext = resolutionContext.getSubcontext(AttributeQueryContext.class, false); List<AQAttribute> attributesToResolve = null; if (aqcontext != null) { attributesToResolve = aqcontext.getAttributesToResolve(); } // if there are no attributes to resolve from the metadatas, no attribtue query is needed if ((attributesToResolve == null || attributesToResolve.isEmpty()) && requireMetadataAttributes) { log.warn("{} Attributes from the SP Metadata required, but no attributes found", getLogPrefix()); return null; } // Building the Attribute Query AttributeQuery query = attributeQueryBuilder.buildAttributeQuery(queryTarget, keyManager, attributesToResolve); if (query == null) { log.warn("{} Attribute query build failed", getLogPrefix()); return null; } // Method for creating the SOAP Envelope Envelope envelope = createSOAPEnvelope(query); try { Element dom = XMLObjectSupport.marshall(envelope); log.debug("{} Print attribute query with envelope {}", getLogPrefix(), SerializeSupport.prettyPrintXML(dom)); } catch (MarshallingException e) { log.debug("{} Unable to print out created attribute query", getLogPrefix()); } // Create InOutOperationContext to send the soap envelope InOutOperationContext<Envelope, Envelope> ioCtx = new InOutOperationContext<Envelope, Envelope>(null, null); ioCtx.setOutboundMessageContext(new MessageContext<Envelope>()); ioCtx.getOutboundMessageContext().getSubcontext(SOAP11Context.class, true).setEnvelope(envelope); // Get a SOAP CLient HttpSOAPClient soapClient = getSOAPClient(); // Send the AttributeQuery try { soapClient.send(queryTarget.getAttributeQueryURL(), ioCtx); } catch (Exception e) { log.warn("{} Sending SOAP Message failed {}", getLogPrefix(), e); return null; } // Get the Response Envelope Envelope SOAPResponse = ioCtx.getInboundMessageContext().getSubcontext(SOAP11Context.class, false) .getEnvelope(); if (SOAPResponse == null || SOAPResponse.getBody() == null) { log.warn("{} No SOAP Response Recieved", getLogPrefix()); return null; } Response samlResponse = null; final List<XMLObject> bodyElements = SOAPResponse.getBody().getUnknownXMLObjects(); for (XMLObject element : bodyElements) { if (element instanceof Response) { samlResponse = (Response) element; } } if (samlResponse == null) { log.warn("{} SOAP Response Body containts no SAML Response!", getLogPrefix()); return null; } // Log the Response try { Element dom = XMLObjectSupport.marshall(samlResponse); log.debug("{} Print SAML Response: {}", getLogPrefix(), SerializeSupport.prettyPrintXML(dom)); } catch (MarshallingException e) { log.warn("{} Unable to print SAML Response. {}", getLogPrefix(), e); } // Validate the saml response if (!validateResponse(samlResponse, query.getID(), query.getIssueInstant(), queryTarget)) { log.warn("{} SAML Response from the AttributeQuery is not valid!", getLogPrefix()); return null; } // Get the attribute statement final List<AttributeStatement> attributeStatements = samlResponse.getAssertions().get(0) .getAttributeStatements(); // if there is no attribue statement, the method returns null (no attributes) if (attributeStatements == null || attributeStatements.size() == 0) return null; // Create the Attributes to release final List<Attribute> responseAttributes = attributeStatements.get(0).getAttributes(); final Map<String, IdPAttribute> returnMap = new HashMap<>(responseAttributes.size()); for (Attribute responseAttribute : responseAttributes) { final IdPAttribute idpAttribute = new IdPAttribute(responseAttribute.getFriendlyName()); final List<XMLObject> responseAttributeValues = responseAttribute.getAttributeValues(); final ArrayList<IdPAttributeValue<?>> idpAttributeValues = new ArrayList<>( responseAttributeValues.size()); for (XMLObject responseAttributeValue : responseAttributeValues) { if (responseAttributeValue instanceof XSString) { idpAttributeValues .add(StringAttributeValue.valueOf(((XSString) responseAttributeValue).getValue())); } } log.debug("{} New Attribute produced from AttributeStatement, friendly name: {}, name: {}", getLogPrefix(), responseAttribute.getFriendlyName(), responseAttribute.getName()); idpAttribute.setValues(idpAttributeValues); returnMap.put(idpAttribute.getId(), idpAttribute); } log.debug("{} Duration of AQ Data Connector: {}ms", getLogPrefix(), (DateTime.now().getMillis() - start.getMillis())); return returnMap; }
From source file:ch.windmobile.server.mongo.MongoDataSource.java
License:Open Source License
private List<BasicDBObject> getHistoricData(String stationId, DateTime lastUpdate, int duration) { DBCollection dataCollection = database.getCollection(getDataCollectionName(stationId)); long startTime = lastUpdate.getMillis() - duration * 1000; DBObject query = BasicDBObjectBuilder .start("_id", BasicDBObjectBuilder.start("$gte", startTime / 1000).get()).get(); List<BasicDBObject> datas = new ArrayList<BasicDBObject>(); DBCursor cursor = dataCollection.find(query); while (cursor.hasNext()) { datas.add((BasicDBObject) cursor.next()); }/*from w ww . jav a 2 s .co m*/ return datas; }
From source file:ch.windmobile.server.mongo.MongoDataSource.java
License:Open Source License
static protected DateTime getExpirationDate(DateTime now, DateTime lastUpdate) { MutableDateTime expirationDate = new MutableDateTime(lastUpdate.getZone()); if (isSummerFrequency(now)) { expirationDate.setMillis(lastUpdate.getMillis() + 20 * 60 * 1000); if (expirationDate.getHourOfDay() >= 20) { expirationDate.addDays(1);/*from www. j a v a2s . c om*/ expirationDate.setHourOfDay(8); expirationDate.setMinuteOfHour(0); expirationDate.setSecondOfMinute(0); } } else { expirationDate.setMillis(lastUpdate.getMillis() + 60 * 60 * 1000); if (expirationDate.getHourOfDay() >= 17) { expirationDate.addDays(1); expirationDate.setHourOfDay(9); expirationDate.setMinuteOfHour(0); expirationDate.setSecondOfMinute(0); } } return expirationDate.toDateTime(); }
From source file:cn.cuizuoli.appranking.typehandler.DateTimeTypeHandler.java
License:Apache License
@Override public void setNonNullParameter(PreparedStatement ps, int i, DateTime parameter, JdbcType jdbcType) throws SQLException { ps.setTimestamp(i, new Timestamp(parameter.getMillis())); }
From source file:com.ace.erp.handler.mybatis.JodaDateTimeDateTypeHandler.java
@Override public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException { DateTime dateTime = (DateTime) parameter; ps.setDate(i, new Date(dateTime.getMillis())); }
From source file:com.ace.erp.handler.mybatis.JodaDateTimestampTypeHandler.java
@Override public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException { DateTime dateTime = (DateTime) parameter; ps.setTimestamp(i, new Timestamp(dateTime.getMillis())); }
From source file:com.act.lcms.v2.fullindex.Builder.java
License:Open Source License
public void processScan(List<Double> targetMZs, File scanFile) throws RocksDBException, ParserConfigurationException, XMLStreamException, IOException { DateTime start = DateTime.now();/*from w w w.j a va 2 s. co m*/ LOGGER.info("Accessing scan file at %s", scanFile.getAbsolutePath()); LCMSNetCDFParser parser = new LCMSNetCDFParser(); Iterator<LCMSSpectrum> spectrumIterator = parser.getIterator(scanFile.getAbsolutePath()); WriteOptions writeOptions = new WriteOptions(); /* The write-ahead log and disk synchronization features are useful when we need our writes to be durable (i.e. to * survive a crash). However, our index construction is effectively a one-shot deal: if it doesn't succeed, we'll * just start from scratch. Since we don't care about durability while we're constructing the index, the WAL and * sync features eat a lot of disk space and I/O bandwidth, which slows us down. So long as we cleanly close the * index once it's built, nobody has to know that we disabled these features. */ writeOptions.setDisableWAL(true); writeOptions.setSync(false); dbAndHandles.setWriteOptions(writeOptions); // TODO: split targetMZs into batches of ~100k and extract incrementally to allow huge input sets. LOGGER.info("Extracting traces"); List<MZWindow> windows = targetsToWindows(targetMZs); extractTriples(spectrumIterator, windows); LOGGER.info("Writing search targets to on-disk index"); writeWindowsToDB(windows); DateTime end = DateTime.now(); LOGGER.info("Index construction completed in %dms", end.getMillis() - start.getMillis()); }