title: “can't convert from BSON type String to Date” MongoDB for Java 3.5
body: <p>Here the query in Bson : </p>
  
  <pre><code>var match = {
  
  
  $match : {
  
      "dt_extract": {
      "$gte": new ISODate("2016-12-05T13:29:28.737+01:00"),
      "$lte": new ISODate("2017-12-11T13:29:29.929+01:00")
    }
  
  }
  
  
  }
  
  
  var group = {
  
  $group :{
          "_id":{
                  weekNum : {"$isoWeek" :"$dt_extract"} ,
                  year :{"$isoWeekYear": "$dt_extract"},
                  dt_extract_date: "$dt_extract"
          },
  
          "Sum_Reliability_Rate_Numerator":{
          "$sum":"$mlf16_txfiabnum"   
          }
  
  }
  }
  
  var project = {
  
  
  $project: { 
  
      "Sum_Reliability_Rate_Numerator":1
  }
  
  
  }
  
  var sort = {
      $sort :{_id : -1}
  }
  
  
   db.mplf_tmp_v3.aggregate([match,group,project,sort])
  </code></pre>
  
  <p>this request work and i didn't have any problem but when i want to write it in Mongo for Java 3.5 i got the problem to convert Bson type String to Date . </p>
  
  <pre><code>private List&lt;Bson&gt; filtersQueryCard(QueryParamWarningDto queryParamWarningDto) {
  
          List&lt;Bson&gt; filters = new ArrayList&lt;&gt;();
  
          LocalDate localDate = LocalDate.now();
  
          Date date = new Date() ;
  
          DateTimeFormatter sdf1 = DateTimeFormat.forPattern("yyyy-MM-dd");
  
  
          localDate = LocalDate.parse(localDate.toString(), sdf1);
  
          LocalDate localDateMin = localDate.minusWeeks(53);
  
  
          LocalDate localDateMax = localDate;
  
  
          DateTime dateTimeMin = localDateMin.toDateTimeAtCurrentTime();
          DateTime dateTimeMax = localDateMax.toDateTimeAtCurrentTime();
  
  
  
          if (queryParamWarningDto.getIdRefNum() != null) {
  
              filters.add(eq(SupplierIndicatorFieldEnum.MLF16_CODRAFT.getLabel(), queryParamWarningDto.getIdRefNum()));
              filters.add(gte(SupplierIndicatorFieldEnum.DT_EXTRACT.getLabel(), "new ISODate('"+dateTimeMin.toString()+"')"));
              filters.add(lte(SupplierIndicatorFieldEnum.DT_EXTRACT.getLabel(),"new ISODate('"+dateTimeMax.toString()+"')"));
  
          } else {
              filters.add(eq(SupplierIndicatorFieldEnum.MLF16_CPTFOU_SIX.getLabel(), queryParamWarningDto.getIdSupNum()));
              filters.add(eq(SupplierIndicatorFieldEnum.MLF16_CODADRES.getLabel(), queryParamWarningDto.getCodeSuppNum()));
  
              filters.add(gte(SupplierIndicatorFieldEnum.DT_EXTRACT.getLabel(),"new ISODate('"+dateTimeMin.toString()+"')"));
              filters.add(lte(SupplierIndicatorFieldEnum.DT_EXTRACT.getLabel(),"new ISODate('"+dateTimeMax.toString()+"')"));
          }
          return filters;
      }
  
  
  private List&lt;SupplierIndicatorDTOM&gt; getAllIndicatorForSupp(QueryParamWarningDto queryParamWarningDto) {
  
          List&lt;SupplierIndicatorDTOM&gt; results = new ArrayList&lt;&gt;();
  
          List&lt;Bson&gt; filters = filtersQueryCard(queryParamWarningDto);
  
          MongoDatabase database = mongoUtil.mongoClient();
  
          MongoCollection&lt;Document&gt; collection = database.getCollection("mplf_tmp_v3");
  
  
          try {
  
              AggregateIterable&lt;Document&gt; resultMongo = collection.aggregate(Arrays.asList(
                      Aggregates.match(and(filters)),
                      Aggregates.group(and(eq("weekNum", eq("$isoWeek", "$dt_extract"))
                              , eq("year", eq("$isoWeekYear","$dt_extract")),
                              eq("dt_extract_date", "$dt_extract"),
                              eq(SupplierIndicatorFieldEnum.MLF16_TXFIABNUM.getLabel(), SupplierIndicatorFieldEnum.MLF16_TXFIABNUM.getLabel()),
                              eq(SupplierIndicatorFieldEnum.MLF16_TXFIABDEN.getLabel(), SupplierIndicatorFieldEnum.MLF16_TXFIABDEN.getLabel())
                              ), Accumulators.sum("Sum_Reliability_Rate_Numerator", SupplierIndicatorFieldEnum.MLF16_TXFIABNUM.getLabel())
                              , Accumulators.sum("Sum_Reliability_Rate_Denominator", SupplierIndicatorFieldEnum.MLF16_TXFIABDEN.getLabel())
                              , Accumulators.sum("Sum_Doc_Rate_Numerator", SupplierIndicatorFieldEnum.MLF16_TXDOCNUM.getLabel())
                              , Accumulators.sum("Sum_Doc_Rate_Denominator", SupplierIndicatorFieldEnum.MLF16_TXDOCDEN.getLabel())
                              , Accumulators.sum("Sum_Service_Rate_Numerator", SupplierIndicatorFieldEnum.MLF16_TXSERVNUM.getLabel())
                              , Accumulators.sum("Sum_Service_Rate_Denominator", SupplierIndicatorFieldEnum.MLF16_TXSERVDEN.getLabel())),
                      Aggregates.project(include("Sum_Reliability_Rate_Numerator", "Sum_Reliability_Rate_Denominator", "Sum_Doc_Rate_Numerator"
                              , "Sum_Doc_Rate_Denominator", "Sum_Service_Rate_Numerator", "Sum_Service_Rate_Denominator"))));
  </code></pre>