com.samskivert.util
Class CalendarUtil

java.lang.Object
  extended by com.samskivert.util.CalendarUtil

public class CalendarUtil
extends Object

Contains some useful calendar related functions.


Constructor Summary
CalendarUtil()
           
 
Method Summary
static int getDaysBetween(Calendar d1, Calendar d2)
          Returns the difference between the dates represented by the two calendars in days, properly accounting for daylight savings time, leap seconds, etc.
static int getMonthsBetween(Calendar start, Calendar end)
          Returns the number of whole months between the dates represented by the two calendar objects, truncating any remainder.
static long getTimeBetween(long start, long end)
          Returns the absolute difference between two longs, which have the significance of acting as miliseconds since the Epoch.
static void zeroTime(Calendar cal)
          Set all the time components of the passed in calendar to zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalendarUtil

public CalendarUtil()
Method Detail

zeroTime

public static void zeroTime(Calendar cal)
Set all the time components of the passed in calendar to zero.


getTimeBetween

public static long getTimeBetween(long start,
                                  long end)
Returns the absolute difference between two longs, which have the significance of acting as miliseconds since the Epoch.


getDaysBetween

public static int getDaysBetween(Calendar d1,
                                 Calendar d2)
Returns the difference between the dates represented by the two calendars in days, properly accounting for daylight savings time, leap seconds, etc. The order of the two dates in time does not matter, the absolute number of days between them will be returned.

From: http://www.jguru.com/forums/view.jsp?EID=489372

Returns:
the number of days between d1 and d2, 0 if they are the same day.

getMonthsBetween

public static int getMonthsBetween(Calendar start,
                                   Calendar end)
Returns the number of whole months between the dates represented by the two calendar objects, truncating any remainder. The order of the two dates in time does not matter, the absolute number of months between them will be returned.



Copyright © 2000-2008 Michael Bayne. All Rights Reserved.