5858import org .kopi .ebics .session .OrderType ;
5959import org .kopi .ebics .session .Product ;
6060import org .kopi .ebics .utils .Constants ;
61+ import org .kopi .ebics .xml .EbicsXmlFactory ;
6162import org .slf4j .Logger ;
6263import org .slf4j .LoggerFactory ;
6364
@@ -413,6 +414,17 @@ public void sendFile(File file, EbicsOrderType orderType) throws Exception {
413414
414415 public void fetchFile (File file , User user , Product product , EbicsOrderType orderType ,
415416 boolean isTest ) throws IOException , EbicsException {
417+ fetchFile (file , user , product , orderType , null , isTest );
418+ }
419+
420+ /**
421+ * Downloads a file from the bank.
422+ *
423+ * @param downloadParams optional EBICS 3.0 service parameters and report period; with a
424+ * service name set the order is sent as a BTD business transaction format order
425+ */
426+ public void fetchFile (File file , User user , Product product , EbicsOrderType orderType ,
427+ EbicsDownloadParams downloadParams , boolean isTest ) throws IOException , EbicsException {
416428 FileTransfer transferManager ;
417429 EbicsSession session = createSession (user , product );
418430 session .addSessionParam ("FORMAT" , "pain.xxx.cfonb160.dct" );
@@ -425,7 +437,7 @@ public void fetchFile(File file, User user, Product product, EbicsOrderType orde
425437 configuration .getTransferTraceDirectory (user ));
426438
427439 try {
428- transferManager .fetchFile (orderType , file );
440+ transferManager .fetchFile (orderType , downloadParams , file );
429441 } catch (NoDownloadDataAvailableException e ) {
430442 // don't log this exception as an error, caller can decide how to handle
431443 throw e ;
@@ -435,9 +447,22 @@ public void fetchFile(File file, User user, Product product, EbicsOrderType orde
435447 }
436448 }
437449
450+ /**
451+ * Downloads a file for a report period.
452+ *
453+ * <p><b>A {@link Date} is an instant, the EBICS report period is a pair of calendar days.</b>
454+ * The calendar day is therefore read in the timezone of the machine running this code, so a
455+ * {@code Date} at UTC midnight becomes the previous day in any zone west of UTC. Prefer
456+ * {@link #fetchFile(File, User, Product, EbicsOrderType, EbicsDownloadParams, boolean)} with
457+ * {@link java.time.LocalDate} values, which has no timezone in it.
458+ */
438459 public void fetchFile (File file , EbicsOrderType orderType , Date start , Date end ) throws IOException ,
439460 EbicsException {
440- fetchFile (file , defaultUser , defaultProduct , orderType , false );
461+ fetchFile (file , defaultUser , defaultProduct , orderType ,
462+ EbicsDownloadParams .dateRangeOnly (
463+ start == null ? null : EbicsXmlFactory .toLocalDate (start ),
464+ end == null ? null : EbicsXmlFactory .toLocalDate (end )),
465+ false );
441466 }
442467
443468 /**
0 commit comments