Package com.illumon.util.calendar
Class DateStringUtils
java.lang.Object
com.illumon.util.calendar.DateStringUtils
Basic utilities for Date Strings.
To comply with the ISO-8601 standard for dates, Strings should
be of the form "yyyy-MM-dd"
Quiet methods are functionally equivalent to their counterparts,
but assume Date String validity to remove the overhead of checking.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanIs one date after another?static booleanisAfterQuiet(String date1, String date2) Is one date after another? This does not check that dates are formatted correctly.static booleanIs one date before another?static booleanisBeforeQuiet(String date1, String date2) Is one date before another? This does not check that dates are formatted correctly.static StringSubtract a number of days from a given date.static StringminusDaysQuiet(String date, int days) Subtract a number of days from a given date.static intmonthOfYear(String date) Gets the month of the year for the date.static StringAdd a number of days from a given date.static StringplusDaysQuiet(String date, int days) Add a number of days from a given date.
-
Method Details
-
minusDays
Subtract a number of days from a given date.- Parameters:
date- datedays- days to subtract- Returns:
- the day
daysbeforedate
-
minusDaysQuiet
Subtract a number of days from a given date. This does not check that dates are formatted correctly.- Parameters:
date- datedays- days to subtract- Returns:
- the day
daysbeforedate
-
plusDays
Add a number of days from a given date.- Parameters:
date- datedays- days to add- Returns:
- the day
daysafterdate
-
plusDaysQuiet
Add a number of days from a given date. This does not check that dates are formatted correctly.- Parameters:
date- datedays- days to add- Returns:
- the day
daysafterdate
-
isBefore
Is one date before another?- Parameters:
date1- ifnullreturn falsedate2- ifnullreturn false- Returns:
- true if
date1is chronologically beforedate2; false otherwise.
-
isBeforeQuiet
Is one date before another? This does not check that dates are formatted correctly. Could be disastrous ifdate1anddate2are not ISO-8601 compliant!- Parameters:
date1- ifnullreturn falsedate2- ifnullreturn false- Returns:
- true if
date1is chronologically beforedate2; false otherwise.
-
isAfter
Is one date after another?- Parameters:
date1- ifnullreturn falsedate2- ifnullreturn false- Returns:
- true if
date1is chronologically afterdate2; false otherwise.
-
isAfterQuiet
Is one date after another? This does not check that dates are formatted correctly. Could be disastrous ifdate1anddate2are not ISO-8601 compliant!- Parameters:
date1- ifnullreturn falsedate2- ifnullreturn false- Returns:
- true if
date1is chronologically afterdate2; false otherwise.
-
monthOfYear
Gets the month of the year for the date.- Parameters:
date- date; ifnullreturnNULL_INT- Returns:
- month of the year for the date. Jan = 1, Dec = 12
-