svn commit: r607776 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r607776 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java

adrianc
Author: adrianc
Date: Mon Dec 31 13:02:41 2007
New Revision: 607776

URL: http://svn.apache.org/viewvc?rev=607776&view=rev
Log:
New methods for UtilDateTime - get period end Timestamps. The new methods are needed for the forthcoming <set-calendar> simple method operation.

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java?rev=607776&r1=607775&r2=607776&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java Mon Dec 31 13:02:41 2007
@@ -27,7 +27,6 @@
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
@@ -864,6 +863,12 @@
         return retStamp;
     }
 
+    public static Timestamp getMonthEnd(Timestamp stamp, TimeZone timeZone, Locale locale) {
+        Calendar tempCal = toCalendar(stamp, timeZone, locale);
+        tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.getActualMaximum(Calendar.DAY_OF_MONTH), 0, 0, 0);
+        return getDayEnd(new Timestamp(tempCal.getTimeInMillis()), timeZone, locale);
+    }
+
     public static Timestamp getYearStart(Timestamp stamp, TimeZone timeZone, Locale locale) {
         return getYearStart(stamp, 0, 0, 0, timeZone, locale);
     }
@@ -890,6 +895,12 @@
         Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
         retStamp.setNanos(0);
         return retStamp;
+    }
+
+    public static Timestamp getYearEnd(Timestamp stamp, TimeZone timeZone, Locale locale) {
+        Calendar tempCal = toCalendar(stamp, timeZone, locale);
+        tempCal.set(tempCal.get(Calendar.YEAR), tempCal.getActualMaximum(Calendar.MONTH) + 1, 0, 0, 0, 0);
+        return getMonthEnd(new Timestamp(tempCal.getTimeInMillis()), timeZone, locale);
     }
 
     public static int weekNumber(Timestamp stamp, TimeZone timeZone, Locale locale) {