Hans,
It would be better to follow the existing pattern of supplying the Locale and TimeZone arguments to the method: public static int dayNumber(Timestamp stamp, Locale locale, TimeZone timeZone) { Calendar tempCal = toCalendar(stamp, timeZone, locale); return tempCal.get(Calendar.DAY_OF_WEEK); } This will be helpful down the road when your users complain that the project manager component ignores their locale and time zone. ;-) -Adrian [hidden email] wrote: > Author: hansbak > Date: Mon Oct 27 22:54:21 2008 > New Revision: 708444 > > URL: http://svn.apache.org/viewvc?rev=708444&view=rev > Log: > scheduler now takes saturday/sundays into account > > Modified: > ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java > ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java > > Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java?rev=708444&r1=708443&r2=708444&view=diff > ============================================================================== > --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java (original) > +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java Mon Oct 27 22:54:21 2008 > @@ -730,6 +730,17 @@ > public static int weekNumber(Timestamp input) { > return weekNumber(input, TimeZone.getDefault(), Locale.getDefault()); > } > + > + /** > + * returns a day number in a week for a Timestamp input > + * > + * @param input Timestamp date > + * @return A int containing the day number (sunday = 1, saturday = 7) > + */ > + public static int dayNumber(Timestamp stamp) { > + Calendar tempCal = toCalendar(stamp, TimeZone.getDefault(), Locale.getDefault()); > + return tempCal.get(Calendar.DAY_OF_WEEK); > + } > > public static int weekNumber(Timestamp input, int startOfWeek) { > Calendar calendar = Calendar.getInstance(); > > Modified: ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java?rev=708444&r1=708443&r2=708444&view=diff > ============================================================================== > --- ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java (original) > +++ ofbiz/trunk/specialpurpose/projectmgr/src/org/ofbiz/project/Various.java Mon Oct 27 22:54:21 2008 > @@ -21,6 +21,8 @@ > import java.math.BigDecimal; > import java.sql.Timestamp; > import java.util.*; > +import java.lang.*; > +import java.util.TimeZone; > > import javolution.util.FastList; > import javolution.util.FastMap; > @@ -58,7 +60,6 @@ > } > > public static Timestamp calculateCompletionDate(GenericValue task, Timestamp startDate) { > - > Double plannedHours = 0.00; > try { > // get planned hours > @@ -78,9 +79,19 @@ > Debug.logError("Could not updte task: " + e.getMessage(), module); > } > if (plannedHours == 0.00) { > - plannedHours = new Double("24.00"); > + plannedHours = new Double("24.00"); // default length of task is 3 days. > + } > + > + // only add days which are not saturday(7) or sunday(1) > + int days = plannedHours.intValue() / 8; > + while (days > 0) { > + int dayNumber = UtilDateTime.dayNumber(startDate); > + if (dayNumber != 1 && dayNumber != 7) { > + days--; > + } > + startDate = UtilDateTime.addDaysToTimestamp(startDate, 1); > } > - return UtilDateTime.addDaysToTimestamp(startDate, plannedHours / 8); > + return startDate; > } > > public static double calculateActualHours(GenericDelegator delegator, String timesheetId) { > > > |
Free forum by Nabble | Edit this page |