From e879b18def68b803247cb787567d4b00fa264e32 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 9 Jul 2014 14:40:16 -0500 Subject: [PATCH] IDEMPIERE-2011 get a date according to saturday/sunday and non business days / based on patch from Nicolas Micoud (nmicoud) --- .../src/org/compiere/util/TimeUtil.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/org.adempiere.base/src/org/compiere/util/TimeUtil.java b/org.adempiere.base/src/org/compiere/util/TimeUtil.java index 8d2ef215ab..db9b2192f8 100644 --- a/org.adempiere.base/src/org/compiere/util/TimeUtil.java +++ b/org.adempiere.base/src/org/compiere/util/TimeUtil.java @@ -815,4 +815,18 @@ public class TimeUtil return endCal.get(Calendar.YEAR) * 12 + endCal.get(Calendar.MONTH) - (startCal.get(Calendar.YEAR) * 12 + startCal.get(Calendar.MONTH)); } + + /** Returns start date + nbDays which cannot be saturday or sunday or non business days */ + public static Timestamp addOnlyBusinessDays(Timestamp startDate, int nbDays, int clientID, String trxName) + { + Timestamp retValue = startDate; + while (nbDays > 0) { + retValue = TimeUtil.addDays(retValue, 1); + StringBuilder sql = new StringBuilder("SELECT nextBusinessDay(?,?) FROM DUAL"); + retValue = DB.getSQLValueTSEx(trxName, sql.toString(), retValue, clientID); + nbDays--; + } + return retValue; + } + } // TimeUtil