|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jdroid.java.utils.DateUtils
public abstract class DateUtils
Utilities for Dates and Calendars
| Nested Class Summary | |
|---|---|
static class |
DateUtils.DayOfWeek
|
| Field Summary | |
|---|---|
static String |
E_DATE_FORMAT
Date format like Fri |
static String |
EEEE_DATE_FORMAT
Date format like Friday |
static String |
EEEE_MMMD_DATE_FORMAT
Date format like Monday Nov 5 |
static String |
EEEE_MMMDYYYY_DATE_FORMAT
Date format like Monday Nov 5 1985 |
static String |
EEEEDMMMM_DATE_FORMAT
Date format like Friday 5 November |
static String |
EEEEMMMM_DATE_FORMAT
Date format like Friday November |
static String |
EEMMMDYYYY_DATE_FORMAT
Date format like Sat, Dec 15, 2012 |
static String |
EHHMMAA_DATE_FORMAT
Date format like Fri 5:15 AM |
static String |
HHMMAA_DATE_FORMAT
Date format like 03:45 PM |
static long |
MILLIS_PER_DAY
Number of milliseconds in a standard day. |
static long |
MILLIS_PER_HOUR
Number of milliseconds in a standard hour. |
static long |
MILLIS_PER_MINUTE
Number of milliseconds in a standard minute. |
static long |
MILLIS_PER_SECOND
Number of milliseconds in a standard second. |
static String |
MMDDYYYY_DATE_FORMAT
Date format like 10/25/2010 |
static String |
MMDDYYYY_SLASH_DATE_FORMAT
Date format like 10-25-2010 |
static String |
MMDDYYYYHHMM_DATE_FORMAT
Date format like 10/25/2010 21:30 |
static String |
MMMD_DATE_FORMAT
Date format like Nov 5 |
static String |
MMMDHHMMAA_DATE_FORMAT
Date format like Nov 5 3:45 PM |
static String |
MMMDYYYY_DATE_FORMAT
Date format like Nov 5 1985 |
static String |
MMMDYYYYHHMMAA_DATE_FORMAT
Date format like Nov 5 1985 3:45 PM |
static String |
MMMMD_DATE_FORMAT
Date format like November 5 |
static int |
SECONDS_PER_DAY
Seconds in a day |
static int |
SECONDS_PER_HOUR
Seconds in an hour |
static int |
SECONDS_PER_MINUTE
Seconds in a minute |
static int |
WEEK
Seconds in a week |
static String |
YYYYMMDD_DATE_FORMAT
Date format like 2010-10-25 |
static String |
YYYYMMDDHHMMSS_DATE_FORMAT
Date format like 2010-10-25 21:30:00 |
static String |
YYYYMMDDHHMMSSZ_DATE_FORMAT
Date format like yyyy-MM-dd HH:mm:ss Z |
static String |
YYYYMMDDTHHMMSSZ_DATE_FORMAT
Date format like yyyy-MM-ddTHH:mm:ss Z |
| Constructor Summary | |
|---|---|
DateUtils()
|
|
| Method Summary | |
|---|---|
static Date |
addDays(Date date,
int days)
|
static Date |
addMonths(Date date,
int days)
|
static Date |
addSeconds(Date date,
int seconds)
|
static Date |
addYears(Date date,
int years)
|
static boolean |
containsPeriod(Date startDate1,
Date endDate1,
Date startDate2,
Date endDate2)
Returns true if the first period contains the second periods |
static String |
format(Date date,
DateFormat dateFormat)
Transform the Date to a String using the received SimpleDateFormat |
static String |
format(Date date,
String dateFormat)
|
static String |
formatDate(Date date)
|
static String |
formatDuration(long duration)
|
static String |
formatTime(Date date)
|
static String |
formatToCardinal(Date date)
Transform the Date to a String with a format like Friday November 5th |
static Date |
getDate(Date date,
Date time)
|
static Date |
getDate(int year,
int monthOfYear,
int dayOfMonth)
Creates a Date for the specified day |
static Date |
getDate(long milliseconds)
|
static int |
getDay(Date date)
|
static int |
getHour(Date date,
Boolean is24Hour)
|
static int |
getHour(Date date,
TimeZone timeZone,
Boolean is24Hour)
|
static Date |
getLastDayOfMonth(Date date)
|
static int |
getMinute(Date date)
|
static int |
getMinute(Date date,
TimeZone timeZone)
|
static int |
getMonth(Date date)
|
static Date |
getTime(int hour,
int minutes)
|
static Date |
getTime(int hour,
int minutes,
Boolean is24Hour)
|
static DateUtils.DayOfWeek |
getWeekDay(Date date)
|
static int |
getYear()
|
static int |
getYear(Date date)
|
static void |
init()
|
static boolean |
isAfter(Date date,
Date dateToCompare)
Tests if the date is after than the specified dateToCompare. |
static boolean |
isAfterEquals(Date date,
Date dateToCompare)
Tests if the date is after or equals than the specified dateToCompare. |
static boolean |
isBefore(Date date,
Date dateToCompare)
Tests if the date is before than the specified dateToCompare. |
static boolean |
isBeforeEquals(Date date,
Date dateToCompare)
Tests if the date is before or equals than the specified dateToCompare. |
static boolean |
isBetween(Date date,
Date startDate,
Date endDate)
|
static Date |
monthsAway(int months)
|
static Date |
now()
|
static Date |
oneMonthInFuture()
|
static Date |
oneMonthInPast()
|
static Date |
parse(String dateFormatted,
SimpleDateFormat dateFormat)
|
static Date |
parse(String dateFormatted,
String dateFormat)
|
static boolean |
periodsOverlap(Date startDate1,
Date endDate1,
Date startDate2,
Date endDate2)
Returns true if two periods overlap |
static Date |
today()
|
static Date |
tomorrow()
|
static void |
truncate(Calendar calendar)
Truncate the Calendar removing hours, minutes, seconds and milliseconds |
static Date |
truncate(Date date)
Truncate the date removing hours, minutes, seconds and milliseconds |
static Date |
yesterday()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int SECONDS_PER_MINUTE
public static final int SECONDS_PER_HOUR
public static final int SECONDS_PER_DAY
public static final int WEEK
public static final long MILLIS_PER_SECOND
public static final long MILLIS_PER_MINUTE
public static final long MILLIS_PER_HOUR
public static final long MILLIS_PER_DAY
public static final String YYYYMMDDTHHMMSSZ_DATE_FORMAT
public static final String YYYYMMDDHHMMSSZ_DATE_FORMAT
public static final String YYYYMMDDHHMMSS_DATE_FORMAT
public static final String MMDDYYYYHHMM_DATE_FORMAT
public static final String MMDDYYYY_DATE_FORMAT
public static final String MMDDYYYY_SLASH_DATE_FORMAT
public static final String YYYYMMDD_DATE_FORMAT
public static final String EHHMMAA_DATE_FORMAT
public static final String E_DATE_FORMAT
public static final String EEEE_DATE_FORMAT
public static final String MMMDHHMMAA_DATE_FORMAT
public static final String MMMDYYYYHHMMAA_DATE_FORMAT
public static final String MMMDYYYY_DATE_FORMAT
public static final String EEEE_MMMDYYYY_DATE_FORMAT
public static final String MMMD_DATE_FORMAT
public static final String EEEE_MMMD_DATE_FORMAT
public static final String MMMMD_DATE_FORMAT
public static final String HHMMAA_DATE_FORMAT
public static final String EEEEDMMMM_DATE_FORMAT
public static final String EEEEMMMM_DATE_FORMAT
public static final String EEMMMDYYYY_DATE_FORMAT
| Constructor Detail |
|---|
public DateUtils()
| Method Detail |
|---|
public static final void init()
public static Date parse(String dateFormatted,
String dateFormat)
dateFormatted - The formatted string to parsedateFormat -
public static Date parse(String dateFormatted,
SimpleDateFormat dateFormat)
dateFormatted - The formatted string to parsedateFormat -
public static String formatToCardinal(Date date)
Date to a String with a format like Friday November 5th
date - The Date to be formatted
public static String format(Date date,
String dateFormat)
date - The Date to be formatteddateFormat - The DateFormat used to format the Date
public static String format(Date date,
DateFormat dateFormat)
Date to a String using the received SimpleDateFormat
date - The Date to be formatteddateFormat - The DateFormat used to format the Date
public static String formatDate(Date date)
public static String formatTime(Date date)
public static Date getDate(int year,
int monthOfYear,
int dayOfMonth)
Date for the specified day
year - The yearmonthOfYear - The month number (starting on 0)dayOfMonth - The day of the month
Date
public static Date getDate(Date date,
Date time)
public static Date getDate(long milliseconds)
public static Date getTime(int hour,
int minutes)
public static Date getTime(int hour,
int minutes,
Boolean is24Hour)
public static int getYear()
public static int getYear(Date date)
public static int getMonth(Date date)
public static int getDay(Date date)
public static int getHour(Date date,
Boolean is24Hour)
public static int getHour(Date date,
TimeZone timeZone,
Boolean is24Hour)
public static int getMinute(Date date)
public static int getMinute(Date date,
TimeZone timeZone)
public static DateUtils.DayOfWeek getWeekDay(Date date)
public static Date addSeconds(Date date,
int seconds)
public static Date addDays(Date date,
int days)
public static Date addMonths(Date date,
int days)
public static Date addYears(Date date,
int years)
public static Date truncate(Date date)
date - The Date to truncate
Datepublic static void truncate(Calendar calendar)
Calendar removing hours, minutes, seconds and milliseconds
calendar - The Calendar to truncatepublic static Date now()
public static boolean isBetween(Date date,
Date startDate,
Date endDate)
date - The date to comparestartDate - The left between' sideendDate - The right between's side
true if the date is in the middle of startDate and endDate
public static boolean isBefore(Date date,
Date dateToCompare)
date - the date to compare with the dateToCompare.dateToCompare - the date to compare with the date.
true if the instant of time represented by date object is earlier than the
instant represented by dateToCompare; false otherwise.
public static boolean isBeforeEquals(Date date,
Date dateToCompare)
date - the date to compare with the dateToCompare.dateToCompare - the date to compare with the date.
true if the instant of time represented by date object is earlier or equal than
the instant represented by dateToCompare; false otherwise.
public static boolean isAfterEquals(Date date,
Date dateToCompare)
date - the date to compare with the dateToCompare.dateToCompare - the date to compare with the date.
true if the instant of time represented by date object is later or equal than
the instant represented by dateToCompare; false otherwise.
public static boolean isAfter(Date date,
Date dateToCompare)
date - the date to compare with the dateToCompare.dateToCompare - the date to compare with the date.
true if the instant of time represented by date object is later than the
instant represented by dateToCompare; false otherwise.
public static boolean periodsOverlap(Date startDate1,
Date endDate1,
Date startDate2,
Date endDate2)
startDate1 - the period one start dateendDate1 - the period one end datestartDate2 - the period two start dateendDate2 - the period two end date
public static boolean containsPeriod(Date startDate1,
Date endDate1,
Date startDate2,
Date endDate2)
startDate1 - the period one start dateendDate1 - the period one end datestartDate2 - the period two start dateendDate2 - the period two end date
public static Date tomorrow()
public static Date today()
public static Date yesterday()
public static Date monthsAway(int months)
months - amount of months to move the calendar
months in the future/past. Use negative values for past dates.public static Date oneMonthInFuture()
public static Date oneMonthInPast()
public static Date getLastDayOfMonth(Date date)
date - Date that includes the desired month in order to calculate the last day of that month
public static String formatDuration(long duration)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||