Commit dacf749e by jinfeng.wang

fix

parent 51a9364c
......@@ -7,9 +7,8 @@ import com.mongodb.client.model.Filters;
import org.apache.commons.lang3.StringUtils;
import org.bson.Document;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
......@@ -25,6 +24,12 @@ public class GetPackageFromMongo {
try {
String mongoUrl = "internal-beijing-adServerMongo-virginia-1390640500.us-east-1.elb.amazonaws.com";
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date dt = sdf.parse(sdf.format(date));
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(dt);
rightNow.add(Calendar.DAY_OF_YEAR, -6);
// MongoClientOptions.Builder builder = new MongoClientOptions.Builder()
MongoClientSettings settings = MongoClientSettings.builder()
.retryWrites(true)
......@@ -48,7 +53,7 @@ public class GetPackageFromMongo {
System.out.println("Connect to database successfully");
MongoCollection<Document> collection = mongoDatabase.getCollection("campaign");
MongoCursor<Document> findIterable = collection.find(Filters.eq("advertiserId", 903)).iterator();
MongoCursor<Document> findIterable = collection.find(Filters.and(Filters.gt("startTime", rightNow.getTime().getTime() / 1000), Filters.eq("advertiserId", 903))).iterator();
Set<String> set = new HashSet<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment