Class DateMath
- java.lang.Object
 - 
- com.ibm.fhir.database.utils.common.DateMath
 
 
- 
public class DateMath extends Object
Simple utility class to handle the date arithmetic we need for rolling date-based partitions TODO use java.time instead 
- 
- 
Constructor Summary
Constructors Constructor Description DateMath() 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DateaddDays(Date d, int howMany)Add howMany days to the givenDatestatic DateaddMonths(Date d, int howMany)Add howMany months to the givenDatestatic DateaddSeconds(Date d, int howMany)Add the requested number of seconds to the given datestatic Stringformat(Date d)Format the date value as yyyy-MM-ddstatic Stringformat2(Date d)Alternate format of the date value: yyyyMMddstatic Datemax(Date d1, Date d2)Return the max of 2 datesstatic Dateparse(String str)Parse the date string which is expected to be yyyy-MM-ddstatic DatetruncateToDay(Date d)Truncate the date to the beginning of the daystatic DatetruncateToMonth(Date d)Truncate the date to the midnight on the first day of the month 
 - 
 
- 
- 
Method Detail
- 
addDays
public static Date addDays(Date d, int howMany)
Add howMany days to the givenDate- Parameters:
 d-howMany-- Returns:
 
 
- 
addMonths
public static Date addMonths(Date d, int howMany)
Add howMany months to the givenDate- Parameters:
 d-howMany-- Returns:
 
 
- 
parse
public static Date parse(String str)
Parse the date string which is expected to be yyyy-MM-dd- Parameters:
 str-- Returns:
 
 
- 
format
public static String format(Date d)
Format the date value as yyyy-MM-dd- Parameters:
 d-- Returns:
 
 
- 
format2
public static String format2(Date d)
Alternate format of the date value: yyyyMMdd- Parameters:
 d-- Returns:
 
 
- 
truncateToMonth
public static Date truncateToMonth(Date d)
Truncate the date to the midnight on the first day of the month- Parameters:
 d-- Returns:
 
 
- 
truncateToDay
public static Date truncateToDay(Date d)
Truncate the date to the beginning of the day- Parameters:
 d-- Returns:
 
 
- 
addSeconds
public static Date addSeconds(Date d, int howMany)
Add the requested number of seconds to the given date- Parameters:
 d-howMany-- Returns:
 
 
 - 
 
 -