com.atlassian.greenhopper.util
Class DateUtils

java.lang.Object
  extended by com.atlassian.greenhopper.util.DateUtils

public class DateUtils
extends java.lang.Object


Constructor Summary
DateUtils()
           
 
Method Summary
static org.joda.time.DateTime getTodayAt(org.joda.time.DateTimeZone timeZone)
          Gives today's local (server) time, at the given timezone (keeping the value)
static boolean isInRange(org.joda.time.ReadableInstant date, org.joda.time.ReadableInstant startDate, org.joda.time.ReadableInstant endDate)
          Checks if the given date is in range, meaning equals or larger than the start date and less or equal to the end date.
static boolean isToday(org.joda.time.DateMidnight date)
          Checks whether the given date is today.
static org.joda.time.DateMidnight toDateMidnight(java.util.Date date)
          Convert a java.util.Date instance to DateMidnight.
static org.joda.time.DateMidnight toDateMidnight(java.util.Date date, org.joda.time.DateMidnight defaultDate)
          Convert a java.util.Date instance to DateMidnight.
static org.joda.time.DateMidnight toDateMidnight(java.util.Date date, org.joda.time.DateTimeZone timeZone)
          Convert a java.util.Date instance to DateMidnight.
static org.joda.time.DateMidnight toDateMidnight(java.lang.Long date, org.joda.time.DateTimeZone timeZone)
          Convert a Long instant (milliseconds) to DateMidnight.
static org.joda.time.DateTime toDateTime(java.util.Date date)
          Converts a given date to a DateTime object
static org.joda.time.DateTime toDateTime(java.util.Date date, org.joda.time.DateTimeZone timeZone)
          Converts a given date to a DateTime object, setting the timezone to the given value (while keeping the value)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtils

public DateUtils()
Method Detail

toDateMidnight

public static org.joda.time.DateMidnight toDateMidnight(java.util.Date date,
                                                        org.joda.time.DateTimeZone timeZone)
Convert a java.util.Date instance to DateMidnight. DateMidnight has a fixed time component of 00:00, which is considered the first instant of the day, with the given timeZone.

Returns:
new DateMidnight instance of the same day, or null if the date parameter was null

toDateMidnight

public static org.joda.time.DateMidnight toDateMidnight(java.lang.Long date,
                                                        org.joda.time.DateTimeZone timeZone)
Convert a Long instant (milliseconds) to DateMidnight. DateMidnight has a fixed time component of 00:00, which is considered the first instant of the day, with the given timeZone.

Returns:
new DateMidnight instance of the same day, or null if the date parameter was null

toDateMidnight

public static org.joda.time.DateMidnight toDateMidnight(java.util.Date date)
Convert a java.util.Date instance to DateMidnight. DateMidnight has a fixed time component of 00:00, which is considered the first instant of the day. It is timezone-aware.

Returns:
new DateMidnight instance of the same day, or null if the date parameter was null

toDateMidnight

public static org.joda.time.DateMidnight toDateMidnight(java.util.Date date,
                                                        org.joda.time.DateMidnight defaultDate)
Convert a java.util.Date instance to DateMidnight. DateMidnight has a fixed time component of 00:00, which is considered the first instant of the day. It is timezone-aware.

Returns:
new DateMidnight instance of the same day, or defaultDate if the date parameter was null

isInRange

public static boolean isInRange(org.joda.time.ReadableInstant date,
                                org.joda.time.ReadableInstant startDate,
                                org.joda.time.ReadableInstant endDate)
Checks if the given date is in range, meaning equals or larger than the start date and less or equal to the end date. If start date or end date is null, they're not taken into account, and any date is valid.

Parameters:
date - : the date to check
startDate - : the lower boundary of the range
endDate - : the upper boundary of the range
Returns:
true if the date is equal or between the lower and upper boundary

isToday

public static boolean isToday(org.joda.time.DateMidnight date)
Checks whether the given date is today.


toDateTime

public static org.joda.time.DateTime toDateTime(java.util.Date date)
Converts a given date to a DateTime object


toDateTime

public static org.joda.time.DateTime toDateTime(java.util.Date date,
                                                org.joda.time.DateTimeZone timeZone)
Converts a given date to a DateTime object, setting the timezone to the given value (while keeping the value)


getTodayAt

public static org.joda.time.DateTime getTodayAt(org.joda.time.DateTimeZone timeZone)
Gives today's local (server) time, at the given timezone (keeping the value)



Copyright © 2007-2012 Atlassian. All Rights Reserved.