public class DateUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
NO_YEAR_DATE_FEB29TH
When parsing a date without a year, the system assumes 1970, which wasn't a leap-year.
|
static java.util.TimeZone |
UTC_TIMEZONE |
| Constructor and Description |
|---|
DateUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
formatDate(android.content.Context context,
java.lang.String string)
Same as
formatDate(Context context, String string, boolean longForm), with
longForm set to true by default. |
static java.lang.String |
formatDate(android.content.Context context,
java.lang.String string,
boolean longForm)
Parses the supplied string to see if it looks like a date.
|
static int |
getDayDifference(android.text.format.Time time,
long date1,
long date2)
Determine the difference, in days between two dates.
|
static java.text.DateFormat |
getLocalizedDateFormatWithoutYear(android.content.Context context)
Returns a SimpleDateFormat object without the year fields by using a regular expression
to eliminate the year in the string pattern.
|
static java.util.Date |
getNextAnnualDate(java.util.Calendar target)
Given a calendar (possibly containing only a day of the year), returns the earliest possible
anniversary of the date that is equal to or after the current point in time if the date
does not contain a year, or the date converted to the local time zone (if the date contains
a year.
|
static boolean |
isMonthBeforeDay(android.content.Context context) |
static boolean |
isYearSet(java.util.Calendar cal) |
static java.util.Calendar |
parseDate(java.lang.String string,
boolean mustContainYear)
Parses the supplied string to see if it looks like a date.
|
public static final java.util.TimeZone UTC_TIMEZONE
public static final java.lang.String NO_YEAR_DATE_FEB29TH
public static java.util.Calendar parseDate(java.lang.String string,
boolean mustContainYear)
string - The string representation of the provided datemustContainYear - If true, the string is parsed as a date containing a year. If false,
the string is parsed into a valid date even if the year field is missing.public static boolean isYearSet(java.util.Calendar cal)
public static java.lang.String formatDate(android.content.Context context,
java.lang.String string)
formatDate(Context context, String string, boolean longForm), with
longForm set to true by default.context - Valid contextstring - String representation of a date to parsepublic static java.lang.String formatDate(android.content.Context context,
java.lang.String string,
boolean longForm)
context - Valid contextstring - String representation of a date to parselongForm - If true, return the date formatted into its long string representation.
If false, return the date formatted using its short form representation (i.e. 12/11/2012)public static boolean isMonthBeforeDay(android.content.Context context)
public static java.text.DateFormat getLocalizedDateFormatWithoutYear(android.content.Context context)
public static java.util.Date getNextAnnualDate(java.util.Calendar target)
target - The date we wish to convert(in the UTC time zone).public static int getDayDifference(android.text.format.Time time,
long date1,
long date2)
time - Instance of time object to use for calculations.date1 - First date to check.date2 - Second date to check.