Class DateUtil
java.lang.Object
ubic.gemma.core.util.DateUtil
Date helpers.
Ported in-tree from ubic.basecode.util.DateUtil as part of the Phase 3
baseCode util retirement (see BASECODE_DEP_AUDIT.md). Only the three
methods actually used by Gemma have been carried over:
convertStringToDate(String, String), getRelativeDate(Date, String), and
numberOfSecondsBetweenDates(Collection). Dropped: convertDateToString,
getDateTime, getTodayDate, and the dead datePattern
static.
- Author:
- pavlidis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DateconvertStringToDate(String aMask, String strDate) This method generates a string representation of a date/time in the format you specify on input.static DategetRelativeDate(Date date, String dateString) Turn a string like '-7d' into the date equivalent to "seven days ago".static longCompute the number of seconds spanned by the given dates.
-
Constructor Details
-
DateUtil
public DateUtil()
-
-
Method Details
-
convertStringToDate
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:
-
getRelativeDate
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 to- Returns:
- Date relative to 'now' as modified by the input date string.
-
numberOfSecondsBetweenDates
Compute the number of seconds spanned by the given dates. If no or a single date is provided, returns 0.
-