Java Utililty Methods Day From

List of utility methods to do Day From

Description

The list of methods to do Day From are organized into topic(s).

Method

intgetDaysBetween(int dateInt1, int dateInt2)
gets days between any two dates (integer form) regardless of order
Calendar di1 = convertToCal(dateInt1);
Calendar di2 = convertToCal(dateInt2);
return Math.round(Math.abs(di1.getTimeInMillis() - di2.getTimeInMillis()) / (float) MillisPerDay);
intgetDaysInPastForDate(Date date)
get Days In Past For Date
long age = new Date().getTime() - date.getTime();
return (int) Math.floor(age / DAY_IN_MILLSEC);
LonggetFirstMilliOfDay(Date date)
get First Milli Of Day
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime().getTime();
intgetIntervalInDaysSofar(Date from)
get Interval In Days Sofar
return (int) ((nowDate().getTime() - from.getTime()) / (24 * 60 * 60 * 1000));
DategetLastDay(Date date)
get Last Day
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.DATE, c.get(Calendar.DATE) + 1);
return c.getTime();
DategetNextDay(Date startTime, int n)
get Next Day
Calendar calendar = new GregorianCalendar();
calendar.setTime(startTime);
calendar.add(Calendar.DATE, n);
return calendar.getTime();
StringgetNextDay(String date)
get Next Day
String ret = "";
int mm = 0, dd = 0, yy = 0;
if (date != null) {
    String[] arr = date.split("/");
    if (arr.length == 3) {
        try {
            mm = Integer.parseInt(arr[0]);
            dd = Integer.parseInt(arr[1]);
...
DategetNoonOfDay(Date day)
get Noon Of Day
if (day == null)
    day = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(day);
calendar.set(Calendar.HOUR_OF_DAY, 12);
calendar.set(Calendar.MINUTE, calendar.getMinimum(Calendar.MINUTE));
calendar.set(Calendar.SECOND, calendar.getMinimum(Calendar.SECOND));
calendar.set(Calendar.MILLISECOND, calendar.getMinimum(Calendar.MILLISECOND));
...
StringgetPlusDay(String _oneDay, int _aFewDays)
get Plus Day
_oneDay = deleteDash(_oneDay);
_oneDay = deleteSlash(_oneDay);
String res;
int year = Integer.parseInt(_oneDay.substring(0, 4));
int month = Integer.parseInt(_oneDay.substring(4, 6));
int day = Integer.parseInt(_oneDay.substring(6, 8));
Calendar wCal = Calendar.getInstance();
wCal.set(year, month - 1, day);
...
intgetServerOffset(boolean useDaylightSavingTime)
get Server Offset
boolean observingDaylightSavingTime = false;
final int DST = 1;
Calendar today = new GregorianCalendar();
TimeZone serverTimeZone = TimeZone.getTimeZone("America/New_York");
int offsetMilliseconds = serverTimeZone.getOffset(today.getTime().getTime());
int offsetHours = (offsetMilliseconds / 3600000);
if (offsetHours == -4) {
    observingDaylightSavingTime = true;
...