From 9dbbcd1082332cbd12e623eff351babaaa88a7c3 Mon Sep 17 00:00:00 2001 From: Adrian Crum Date: Tue, 4 Aug 2009 23:38:55 +0000 Subject: [PATCH] Fixed a bug in UtilDateTime.java - getWeekEnd() returned the wrong value. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@801023 13f79535-47bb-0310-9956-ffa450edef68 --- .../base/src/org/ofbiz/base/util/UtilDateTime.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/framework/base/src/org/ofbiz/base/util/UtilDateTime.java b/framework/base/src/org/ofbiz/base/util/UtilDateTime.java index dd1f3c2996..61a46a041e 100644 --- a/framework/base/src/org/ofbiz/base/util/UtilDateTime.java +++ b/framework/base/src/org/ofbiz/base/util/UtilDateTime.java @@ -851,14 +851,10 @@ public class UtilDateTime { } public static Timestamp getWeekEnd(Timestamp stamp, TimeZone timeZone, Locale locale) { - Calendar tempCal = toCalendar(stamp, timeZone, locale); - tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); - tempCal.add(Calendar.WEEK_OF_MONTH, 1); - tempCal.set(Calendar.DAY_OF_WEEK, tempCal.getFirstDayOfWeek()); - tempCal.add(Calendar.SECOND, -1); - Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis()); - retStamp.setNanos(999999999); - return retStamp; + Timestamp weekStart = getWeekStart(stamp, timeZone, locale); + Calendar tempCal = toCalendar(weekStart, timeZone, locale); + tempCal.add(Calendar.DAY_OF_MONTH, 6); + return getDayEnd(new Timestamp(tempCal.getTimeInMillis()), timeZone, locale); } public static Timestamp getMonthStart(Timestamp stamp, TimeZone timeZone, Locale locale) {