Java Utililty Methods Week Day

List of utility methods to do Week Day

Description

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

Method

intgetDayOfWeek(long date)
Returns the day of the week.
Calendar calendar = CALENDAR;
synchronized (calendar) {
    calendar.setTimeInMillis(date);
    return (calendar.get(Calendar.DAY_OF_WEEK));
intgetDayOfWeek(long date)
Returns the day of the week.
Calendar calendar = CALENDAR;
synchronized (calendar) {
    calendar.setTimeInMillis(date);
    return (calendar.get(Calendar.DAY_OF_WEEK));
intGetDayOfWeek(long p)
Get Day Of Week
Date t = long2Date(p);
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(t);
switch (gc.get(Calendar.DAY_OF_WEEK)) {
case Calendar.SUNDAY:
    return 0;
case Calendar.MONDAY:
    return 1;
...
StringgetDayOfWeek(String dat)
get Day Of Week
dat = dat.replaceAll("-", "");
int yy = Integer.valueOf(dat.substring(0, 4)).intValue();
int mm = Integer.valueOf(dat.substring(4, 6)).intValue();
int dd = Integer.valueOf(dat.substring(6)).intValue();
String[] dayOfWeek = { "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
Calendar c = Calendar.getInstance();
c.set(yy, mm - 1, dd);
return dayOfWeek[c.get(Calendar.DAY_OF_WEEK) - 1];
...
intgetDayOfWeek(String date)
get Day Of Week
String[] temp = null;
if (date.indexOf("/") > 0) {
    temp = date.split("/");
if (date.indexOf("-") > 0) {
    temp = date.split("-");
return getDayOfWeek(temp[0], temp[1], temp[2]);
...
intgetDayOfWeek(String year, String month, String day)
get Day Of Week
Calendar cal = new GregorianCalendar(new Integer(year).intValue(), new Integer(month).intValue() - 1,
        new Integer(day).intValue());
return cal.get(Calendar.DAY_OF_WEEK);
StringgetDayOfWeekAbbreviation(int day)
get Day Of Week Abbreviation
switch (day) {
case java.util.Calendar.SUNDAY:
    return "SU";
case java.util.Calendar.SATURDAY:
    return "SA";
case java.util.Calendar.FRIDAY:
    return "FR";
case java.util.Calendar.THURSDAY:
...
StringgetDayOfWeekAbreviated(Date d)
get Day Of Week Abreviated
Calendar cal = Calendar.getInstance();
cal.setTime(d);
int ret = cal.get(Calendar.DAY_OF_WEEK);
if (ret == Calendar.MONDAY)
    return "Seg";
if (ret == Calendar.TUESDAY)
    return "Ter";
if (ret == Calendar.WEDNESDAY)
...
StringgetDayOfWeekShortString(Date date)
get Day Of Week Short String
int dayOfWeek = getDayOfWeek(date);
switch (dayOfWeek) {
case 1:
    return "Sun";
case 2:
    return "Mon";
case 3:
    return "Tue";
...
intgetDaysExceptWeekend(String from, String to)
get Days Except Weekend
if (from.compareTo(to) > 0) {
    String tmp = from;
    from = to;
    to = tmp;
Calendar begin = parseCalendar(from);
Calendar end = parseCalendar(to);
int sum = 0;
...