Java Code Examples for org.bson.BsonDateTime#getValue()

The following examples show how to use org.bson.BsonDateTime#getValue() . 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: ChronoGraph.java    From epcis with Apache License 2.0 6 votes vote down vote up
/**
 * Return non-redundant timestamps of all graph element events
 * 
 * @return HashSet<Long> timestamps
 */
public TreeSet<Long> getTimestamps() {
	TreeSet<Long> timestampSet = new TreeSet<Long>();

	Function<BsonDateTime, Long> mapper = new Function<BsonDateTime, Long>() {
		@Override
		public Long apply(BsonDateTime val) {
			return val.getValue();
		}

	};
	edgeEvents.distinct(Tokens.TIMESTAMP, BsonDateTime.class)
			.filter(new BsonDocument(Tokens.TIMESTAMP, new BsonDocument(Tokens.FC.$ne.toString(), new BsonNull())))
			.map(mapper).into(timestampSet);
	Set<Long> vtSet = new TreeSet<Long>();

	vertexEvents.distinct(Tokens.TIMESTAMP, BsonDateTime.class)
			.filter(new BsonDocument(Tokens.TIMESTAMP, new BsonDocument(Tokens.FC.$ne.toString(), new BsonNull())))
			.map(mapper).into(vtSet);
	timestampSet.addAll(vtSet);

	return timestampSet;
}
 
Example 2
Source File: ChronoGraph.java    From epcis with Apache License 2.0 6 votes vote down vote up
public TreeSet<Long> getTimestamps(Long startTime, Long endTime) {
	TreeSet<Long> timestampSet = new TreeSet<Long>();

	Function<BsonDateTime, Long> mapper = new Function<BsonDateTime, Long>() {
		@Override
		public Long apply(BsonDateTime val) {
			return val.getValue();
		}

	};
	edgeEvents.distinct(Tokens.TIMESTAMP, BsonDateTime.class)
			.filter(new BsonDocument(Tokens.TIMESTAMP,
					new BsonDocument(Tokens.FC.$gt.toString(), new BsonDateTime(startTime))
							.append(Tokens.FC.$lt.toString(), new BsonDateTime(endTime))))
			.map(mapper).into(timestampSet);
	Set<Long> vtSet = new TreeSet<Long>();

	vertexEvents.distinct(Tokens.TIMESTAMP, BsonDateTime.class)
			.filter(new BsonDocument(Tokens.TIMESTAMP,
					new BsonDocument(Tokens.FC.$gt.toString(), new BsonDateTime(startTime))
							.append(Tokens.FC.$lt.toString(), new BsonDateTime(endTime))))
			.map(mapper).into(timestampSet);
	timestampSet.addAll(vtSet);

	return timestampSet;
}
 
Example 3
Source File: ChronoGraph.java    From epcis with Apache License 2.0 6 votes vote down vote up
public HashSet<Long> getTimestampsHashSet() {
	HashSet<Long> timestampSet = new HashSet<Long>();

	Function<BsonDateTime, Long> mapper = new Function<BsonDateTime, Long>() {
		@Override
		public Long apply(BsonDateTime val) {
			return val.getValue();
		}

	};
	edges.distinct(Tokens.TIMESTAMP, BsonDateTime.class)
			.filter(new BsonDocument(Tokens.TIMESTAMP, new BsonDocument(Tokens.FC.$ne.toString(), new BsonNull())))
			.map(mapper).into(timestampSet);

	return timestampSet;
}
 
Example 4
Source File: MongoReaderUtil.java    From epcis with Apache License 2.0 4 votes vote down vote up
static String getDateStream(BsonDateTime bdt) {
	Date date = new Date(bdt.getValue());
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
	return sdf.format(date);
}
 
Example 5
Source File: MongoReaderUtil.java    From epcis with Apache License 2.0 4 votes vote down vote up
static String getDateStream(BsonDateTime bdt) {
	Date date = new Date(bdt.getValue());
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
	return sdf.format(date);
}