Package ubic.basecode.util
Class DateUtil
- java.lang.Object
-
- ubic.basecode.util.DateUtil
-
public class DateUtil extends Object
Date Utility Class- Version:
- $Revision$ $Date$
- Author:
- pavlidis, Matt Raible Modified by Dan Kibler to correct time pattern. Minutes should be mm not MM (MM is month).
-
-
Constructor Summary
Constructors Constructor Description DateUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
convertDateToString(Date aDate)
This method generates a string representation of a date based on the System Property 'dateFormat' in the format you specify on inputstatic Date
convertStringToDate(String aMask, String strDate)
This method generates a string representation of a date/time in the format you specify on inputstatic String
getDateTime(String aMask, Date aDate)
This method generates a string representation of a date's date/time in the format you specify on inputstatic Date
getRelativeDate(Date date, String dateString)
Turn a string like '-7d' into the date equivalent to "seven days ago".static String
getTodayDate(boolean changeDateformat)
return today date as a Stringstatic long
numberOfSecondsBetweenDates(Collection<Date> dates)
Compute the number of seconds spanned by the given dates.
-
-
-
Method Detail
-
convertDateToString
public static final String convertDateToString(Date aDate)
This method generates a string representation of a date based on the System Property 'dateFormat' in the format you specify on input- Parameters:
aDate
- A date to convert- Returns:
- a string representation of the date
-
convertStringToDate
public static final Date convertStringToDate(String aMask, String strDate) throws ParseException
This method generates a string representation of a date/time in the format you specify on input- Parameters:
aMask
- the date pattern the string is instrDate
- a string representation of a date- Returns:
- a converted Date object
- Throws:
ParseException
- See Also:
SimpleDateFormat
-
getDateTime
public static final String getDateTime(String aMask, Date aDate)
This method generates a string representation of a date's date/time in the format you specify on input- Parameters:
aMask
- the date pattern the string is inaDate
- a date object- Returns:
- a formatted string representation of the date
- See Also:
SimpleDateFormat
-
getRelativeDate
public static Date getRelativeDate(Date date, String dateString)
Turn a string like '-7d' into the date equivalent to "seven days ago". Supports 'd' for day, 'h' for hour, 'm' for minutes, "M" for months and "y" for years. Start with a '-' to indicate times in the past ('+' is not necessary for future). Values must be integers.- Parameters:
date
- to be added/subtracted todateString
-- Returns:
- Date relative to 'now' as modified by the input date string.
-
getTodayDate
public static String getTodayDate(boolean changeDateformat)
return today date as a String- Parameters:
boolean
- changes character '\' to '-', (used to write files)- Returns:
- String today date
-
numberOfSecondsBetweenDates
public static long numberOfSecondsBetweenDates(Collection<Date> dates)
Compute the number of seconds spanned by the given dates. If no or a single date is provided, returns 0.- Parameters:
dates
-- Returns:
-
-