org.enblom.time
Class TimeUtils

java.lang.Object
  extended by org.enblom.time.TimeUtils

public class TimeUtils
extends Object

Utilities for dealing with Time and similar objects.

Author:
Andreas Enblom

Constructor Summary
TimeUtils()
           
 
Method Summary
static int differenceInDays(DayDate later, DayDate earlier)
          Calculates the difference in whole days between the two given date.
static int differenceInDays(Time later, Time earlier)
          Calculates the difference in whole days between the two given times.
static DayDate max(DayDate d1, DayDate d2)
          Finds the maximum of two dates.
static TimeOfDay max(TimeOfDay t1, TimeOfDay t2)
          Finds the maximum of two times.
static Time max(Time t1, Time t2)
          Finds the maximum of two times.
static DayDate min(DayDate d1, DayDate d2)
          Finds the minimum of two dates.
static TimeOfDay min(TimeOfDay t1, TimeOfDay t2)
          Finds the minimum of two times.
static Time min(Time t1, Time t2)
          Finds the minimum of two times.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeUtils

public TimeUtils()
Method Detail

min

public static Time min(Time t1,
                       Time t2)
Finds the minimum of two times.

Parameters:
t1 - The first time.
t2 - The last time
Returns:
The minimum (i.e. earliest) of the two times.

max

public static Time max(Time t1,
                       Time t2)
Finds the maximum of two times.

Parameters:
t1 - The first time.
t2 - The last time
Returns:
The maximum (i.e. latest) of the two times.

min

public static DayDate min(DayDate d1,
                          DayDate d2)
Finds the minimum of two dates.

Parameters:
d1 - The first date.
d2 - The last date
Returns:
The minimum (i.e. earliest) of the two date.

max

public static DayDate max(DayDate d1,
                          DayDate d2)
Finds the maximum of two dates.

Parameters:
d1 - The first time.
d2 - The last time
Returns:
The maximum (i.e. latest) of the two dates.

min

public static TimeOfDay min(TimeOfDay t1,
                            TimeOfDay t2)
Finds the minimum of two times.

Parameters:
t1 - The first time.
t2 - The last time
Returns:
The minimum (i.e. earliest) of the two times.

max

public static TimeOfDay max(TimeOfDay t1,
                            TimeOfDay t2)
Finds the maximum of two times.

Parameters:
t1 - The first time.
t2 - The last time
Returns:
The maximum (i.e. latest) of the two times.

differenceInDays

public static int differenceInDays(Time later,
                                   Time earlier)
Calculates the difference in whole days between the two given times. Only the date part of the timestamp is considered, so the difference between 2011-06-04 00:01 and 2011-06-03 23:59 is one day. The sign of this difference assumes that the first argument is later than the second argument, if not, the calculated difference will be negative. Two times representing the same day will have zero difference.

Parameters:
later - The first time to compare.
earlier - The second time to compare.
Returns:
The difference in whole days between the two given times. This is positive if the first argument represents a later day than the second argument, negative if the first argument represents an earlier day than the second argument, and zero if both arguments represent the same day.

differenceInDays

public static int differenceInDays(DayDate later,
                                   DayDate earlier)
Calculates the difference in whole days between the two given date. For instance, the difference between 2011-06-04 and 2011-06-03 is one day. The sign of this difference assumes that the first argument is later than the second argument, if not, the calculated difference will be negative. Two arguments representing the same day will have zero difference.

Parameters:
later - The first time to compare.
earlier - The second time to compare.
Returns:
The difference in whole days between the two given dates. This is positive if the first argument represents a later day than the second argument, negative if the first argument represents an earlier day than the second argument, and zero if both arguments represent the same day.


Copyright © 2011. All Rights Reserved.