Package com.illumon.util.calendar
Class DateStringUtils
java.lang.Object
com.illumon.util.calendar.DateStringUtils
public class DateStringUtils extends Object
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 Type Method Description static boolean
isAfter(String date1, String date2)
Is one date after another?static boolean
isAfterQuiet(String date1, String date2)
Is one date after another? This does not check that dates are formatted correctly.static boolean
isBefore(String date1, String date2)
Is one date before another?static boolean
isBeforeQuiet(String date1, String date2)
Is one date before another? This does not check that dates are formatted correctly.static String
minusDays(String date, int days)
Subtract a number of days from a given date.static String
minusDaysQuiet(String date, int days)
Subtract a number of days from a given date.static int
monthOfYear(String date)
Gets the month of the year for the date.static String
plusDays(String date, int days)
Add a number of days from a given date.static String
plusDaysQuiet(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
days
beforedate
-
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
days
beforedate
-
plusDays
Add a number of days from a given date.- Parameters:
date
- datedays
- days to add- Returns:
- the day
days
afterdate
-
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
days
afterdate
-
isBefore
Is one date before another?- Parameters:
date1
- ifnull
return falsedate2
- ifnull
return false- Returns:
- true if
date1
is chronologically beforedate2
; false otherwise.
-
isBeforeQuiet
Is one date before another? This does not check that dates are formatted correctly. Could be disastrous ifdate1
anddate2
are not ISO-8601 compliant!- Parameters:
date1
- ifnull
return falsedate2
- ifnull
return false- Returns:
- true if
date1
is chronologically beforedate2
; false otherwise.
-
isAfter
Is one date after another?- Parameters:
date1
- ifnull
return falsedate2
- ifnull
return false- Returns:
- true if
date1
is chronologically afterdate2
; false otherwise.
-
isAfterQuiet
Is one date after another? This does not check that dates are formatted correctly. Could be disastrous ifdate1
anddate2
are not ISO-8601 compliant!- Parameters:
date1
- ifnull
return falsedate2
- ifnull
return false- Returns:
- true if
date1
is chronologically afterdate2
; false otherwise.
-
monthOfYear
Gets the month of the year for the date.- Parameters:
date
- date; ifnull
returnNULL_INT
- Returns:
- month of the year for the date. Jan = 1, Dec = 12
-