Java Utililty Methods Day of

List of utility methods to do Day of

Description

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

Method

StringgetThursday(String date)
get Thursday
Date d = strToDtSimpleFormat(date);
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
return dateFormat(cal.getTime());
floatgetTimeOfDaySeconds()
Calculates current time as a float
return (((Float.parseFloat(hour.format(cal.getTime())) * 3600)
        + (Float.parseFloat(minute.format(cal.getTime())) * 60)
        + Float.parseFloat(second.format(cal.getTime()))) * 1000);
StringgetTimestamp(String format, Integer daysInFuture)
get Timestamp
Calendar c = Calendar.getInstance();
if (daysInFuture != null)
    c.add(Calendar.DAY_OF_YEAR, daysInFuture);
return new SimpleDateFormat(format).format(c.getTime());
StringgetTwoDay(String sj1, String sj2)
get Two Day
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
long day = 0;
try {
    Date date = myFormatter.parse(sj1);
    Date mydate = myFormatter.parse(sj2);
    day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
} catch (Exception e) {
    return "";
...
StringgetTwoDay(String sj1, String sj2)
get Two Day
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
long day = 0;
try {
    java.util.Date date = myFormatter.parse(sj1);
    java.util.Date mydate = myFormatter.parse(sj2);
    day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
} catch (Exception e) {
    return "";
...
StringgetTwoDay2String(String startDate, String endDate, Format format)
get Two Day String
SimpleDateFormat localFormat = (SimpleDateFormat) format;
long day = 0;
try {
    java.util.Date startDay = localFormat.parse(startDate);
    java.util.Date endDay = localFormat.parse(endDate);
    day = (endDay.getTime() - startDay.getTime()) / (24 * 60 * 60 * 1000);
} catch (Exception e) {
    return "";
...
intgetWorkingDay(Calendar d1, Calendar d2)
get Working Day
int result = -1;
if (d1.after(d2)) { 
    Calendar swap = d1;
    d1 = d2;
    d2 = swap;
int charge_start_date = 0;
int charge_end_date = 0;
...
StringgetYesday()
get Yesday
String strDate = getCurrenDateTime();
Calendar cale = toCalendar(strDate);
cale.add(Calendar.DAY_OF_YEAR, -1);
return dateFormatterByPattern(cale.getTime(), "yyyy-MM-dd");
StringgetYYYY_MM_DD(int offsetDays)
get YYYMDD
Calendar calendar = Calendar.getInstance();
if (offsetDays != 0)
    calendar.add(Calendar.DATE, offsetDays);
Date date = calendar.getTime();
return formatDD(date);
booleanisBirthdayPartAvail(String number)
is Birthday Part Avail
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
simpleDateFormat.setLenient(false);
Date date = null;
try {
    date = simpleDateFormat.parse(number.substring(6, 14));
} catch (ParseException e) {
    return false;
return date.before(new Date());