java.util.Calendar#SUNDAY源码实例Demo

下面列出了java.util.Calendar#SUNDAY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tddl5   文件: Weekday.java
@Override
public Object compute(Object[] args, ExecutionContext ec) {
    for (Object arg : args) {
        if (ExecUtils.isNull(arg)) {
            return null;
        }
    }

    java.sql.Timestamp timestamp = DataType.TimestampType.convertFrom(args[0]);
    Calendar cal = Calendar.getInstance();
    cal.setTime(timestamp);

    int week = cal.get(Calendar.DAY_OF_WEEK);
    if (week == Calendar.SUNDAY) {
        return 6;
    } else {
        return week - 2;
    }
}
 
源代码2 项目: oneHookLibraryAndroid   文件: OHDateUtils.java
public static int getTodayWeekdayNormalized() {
    final Calendar calendar = Calendar.getInstance();
    final int weekday = calendar.get(Calendar.DAY_OF_WEEK);
    switch (weekday) {
        case Calendar.SUNDAY:
            return 0;
        case Calendar.MONDAY:
            return 1;
        case Calendar.TUESDAY:
            return 2;
        case Calendar.WEDNESDAY:
            return 3;
        case Calendar.THURSDAY:
            return 4;
        case Calendar.FRIDAY:
            return 5;
        case Calendar.SATURDAY:
            return 6;
        default:
            return 0;
    }
}
 
源代码3 项目: unitime   文件: Event.java
public String getDays(String[] dayNames, String[] shortDyNames) {
    int nrDays = 0;
    int dayCode = 0;
    for (Meeting meeting : getMeetings()) {
        int dc = 0;
        switch (meeting.getDayOfWeek()) {
           case Calendar.MONDAY    : dc = Constants.DAY_CODES[Constants.DAY_MON]; break;
           case Calendar.TUESDAY   : dc = Constants.DAY_CODES[Constants.DAY_TUE]; break;
           case Calendar.WEDNESDAY : dc = Constants.DAY_CODES[Constants.DAY_WED]; break;
           case Calendar.THURSDAY  : dc = Constants.DAY_CODES[Constants.DAY_THU]; break;
           case Calendar.FRIDAY    : dc = Constants.DAY_CODES[Constants.DAY_FRI]; break;
           case Calendar.SATURDAY  : dc = Constants.DAY_CODES[Constants.DAY_SAT]; break;
           case Calendar.SUNDAY    : dc = Constants.DAY_CODES[Constants.DAY_SUN]; break;
        }
        if ((dayCode & dc)==0) nrDays++;
        dayCode |= dc;
    }
       String ret = "";
    for (int i=0;i<Constants.DAY_CODES.length;i++) {
        if ((dayCode & Constants.DAY_CODES[i])!=0)
            ret += (nrDays==1?dayNames:shortDyNames)[i];
    }
       return ret;
}
 
源代码4 项目: o2oa   文件: DateHelper.java
/**
 * 获取星期几
 *
 * @param date
 * @param format
 * @return 周日 周一 周二 周三 周四 周五 周六
 * @throws ParseException
 */
public static String getWeekDay(String date, String format) throws ParseException {
    Calendar c = gc(date, format);
    if (c != null) {
        int weekDay = c.get(Calendar.DAY_OF_WEEK);
        switch (weekDay) {
            case Calendar.SUNDAY:
                return "周日";
            case Calendar.MONDAY:
                return "周一";
            case Calendar.TUESDAY:
                return "周二";
            case Calendar.WEDNESDAY:
                return "周三";
            case Calendar.THURSDAY:
                return "周四";
            case Calendar.FRIDAY:
                return "周五";
            case Calendar.SATURDAY:
                return "周六";
        }
    }
    return "";

}
 
源代码5 项目: arcusandroid   文件: TimeWindowModel.java
protected String getCalendarAbbrFor(int day) {
    switch (day) {
        case Calendar.MONDAY: return "Mo";
        case Calendar.TUESDAY: return "Tu";
        case Calendar.WEDNESDAY: return "We";
        case Calendar.THURSDAY: return "Th";
        case Calendar.FRIDAY: return "Fr";

        default:
        case Calendar.SUNDAY: return "Su";
    }
}
 
源代码6 项目: ClockPlus   文件: AlarmTest.java
@Test
public void alarm_RingsAt_BackwardQueueingRecurringDays() {
    Calendar cal = new GregorianCalendar();
    int D_C = cal.get(Calendar.DAY_OF_WEEK);

    for (int h = 0; h < 24; h++) {
        for (int m = 0; m < 60; m++) {
            Alarm a = Alarm.builder().hour(h).minutes(m).build();
            for (int D = Calendar.SATURDAY; D >= Calendar.SUNDAY; D--) {
                out.println("Testing (h, m, d) = ("+h+", "+m+", "+ (D-1) +")");
                int hC = cal.get(HOUR_OF_DAY); // Current hour
                int mC = cal.get(MINUTE);      // Current minute
                a.setRecurring(D - 1, true);

                int days = 0;

                if (h > hC || (h == hC && m > mC)) {
                    if (D < D_C) {
                        days = Calendar.SATURDAY - D_C + D;
                    } else if (D == D_C) {
                        days = 0; // upcoming on the same day
                    } else {
                        days = D - D_C;
                    }
                } else if (h <= hC) {
                    if (D < D_C) {
                        days = Calendar.SATURDAY - D_C + D - 1;
                    } else if (D == D_C) {
                        days = 0;
                    } else {
                        days = D - D_C - 1;
                    }
                }
                
                calculateRingTimeAndTest(h, m, days, cal, a.ringsAt());
            }
        }
    }
}
 
源代码7 项目: sakai   文件: CalendarUtil.java
/**
* Get the day of the week
  *
  * @param useLocale return locale specific day of week
* e.g. <code>SUNDAY = 1, MONDAY = 2, ...</code> in the U.S.,
*		 <code>MONDAY = 1, TUESDAY = 2, ...</code> in France. 
* @return the day of the week.
*/
public int getDay_Of_Week( boolean useLocale ) 
{
	int dayofweek = m_calendar.get(Calendar.DAY_OF_WEEK);
	if ( useLocale )
	{
		if ( dayofweek >= m_calendar.getFirstDayOfWeek() )
			dayofweek = dayofweek - (m_calendar.getFirstDayOfWeek()-Calendar.SUNDAY);
		else
			dayofweek = dayofweek + Calendar.SATURDAY - (m_calendar.getFirstDayOfWeek()-Calendar.SUNDAY);
	}
	return dayofweek;

}
 
源代码8 项目: o2oa   文件: DateOperation.java
/**
 * 判断是否周末
 * @param recordDate
 * @return
 */
public boolean isWeekend(Date date) {
	Calendar cal = Calendar.getInstance();
    cal.setTime( date );
    if(cal.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY||cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
       return true;
    }
	return false;
}
 
源代码9 项目: AlipayWechatPlatform   文件: DateUtil.java
/**
 * 根据日期,返回其星期数,周一为1,周日为7
 * @param date
 * @return
 */
public static int getWeekDay(Date date) {
	Calendar calendar = Calendar.getInstance();
	calendar.setTime(date);
	int w = calendar.get(Calendar.DAY_OF_WEEK);
	int ret;
	if (w == Calendar.SUNDAY)
		ret = 7;
	else
		ret = w - 1;
	return ret;
}
 
源代码10 项目: AlarmOn   文件: DatePickerDialog.java
@SuppressWarnings("unused")
public void setFirstDayOfWeek(int startOfWeek) {
    if (startOfWeek < Calendar.SUNDAY || startOfWeek > Calendar.SATURDAY) {
        throw new IllegalArgumentException("Value must be between Calendar.SUNDAY and " +
                "Calendar.SATURDAY");
    }
    mWeekStart = startOfWeek;
    if (mDayPickerView != null) {
        mDayPickerView.onChange();
    }
}
 
源代码11 项目: Java8CN   文件: DateTimeTextProvider.java
private static int toWeekDay(int calWeekDay) {
    if (calWeekDay == Calendar.SUNDAY) {
        return 7;
    } else {
        return calWeekDay - 1;
    }
}
 
源代码12 项目: JDKSourceCode1.8   文件: DateTimeTextProvider.java
private static int toWeekDay(int calWeekDay) {
    if (calWeekDay == Calendar.SUNDAY) {
        return 7;
    } else {
        return calWeekDay - 1;
    }
}
 
源代码13 项目: jdk8u-jdk   文件: DateTimeTextProvider.java
private static int toWeekDay(int calWeekDay) {
    if (calWeekDay == Calendar.SUNDAY) {
        return 7;
    } else {
        return calWeekDay - 1;
    }
}
 
源代码14 项目: openjdk-8   文件: DateTimeTextProvider.java
private static int toWeekDay(int calWeekDay) {
    if (calWeekDay == Calendar.SUNDAY) {
        return 7;
    } else {
        return calWeekDay - 1;
    }
}
 
源代码15 项目: jdk8u_jdk   文件: DateTimeTextProvider.java
/**
 * Gets the text for the specified chrono, field, locale and style
 * for the purpose of formatting.
 * <p>
 * The text associated with the value is returned.
 * The null return value should be used if there is no applicable text, or
 * if the text would be a numeric representation of the value.
 *
 * @param chrono  the Chronology to get text for, not null
 * @param field  the field to get text for, not null
 * @param value  the field value to get text for, not null
 * @param style  the style to get text for, not null
 * @param locale  the locale to get text for, not null
 * @return the text for the field value, null if no text found
 */
public String getText(Chronology chrono, TemporalField field, long value,
                                TextStyle style, Locale locale) {
    if (chrono == IsoChronology.INSTANCE
            || !(field instanceof ChronoField)) {
        return getText(field, value, style, locale);
    }

    int fieldIndex;
    int fieldValue;
    if (field == ERA) {
        fieldIndex = Calendar.ERA;
        if (chrono == JapaneseChronology.INSTANCE) {
            if (value == -999) {
                fieldValue = 0;
            } else {
                fieldValue = (int) value + 2;
            }
        } else {
            fieldValue = (int) value;
        }
    } else if (field == MONTH_OF_YEAR) {
        fieldIndex = Calendar.MONTH;
        fieldValue = (int) value - 1;
    } else if (field == DAY_OF_WEEK) {
        fieldIndex = Calendar.DAY_OF_WEEK;
        fieldValue = (int) value + 1;
        if (fieldValue > 7) {
            fieldValue = Calendar.SUNDAY;
        }
    } else if (field == AMPM_OF_DAY) {
        fieldIndex = Calendar.AM_PM;
        fieldValue = (int) value;
    } else {
        return null;
    }
    return CalendarDataUtility.retrieveJavaTimeFieldValueName(
            chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale);
}
 
源代码16 项目: j2objc   文件: SimpleTimeZoneTest.java
public void testDstNewYork2014_2ndSundayMarch_1stSundayNovember_StandardTime() {
    TimeZone timeZone = new SimpleTimeZone(NEW_YORK_RAW_OFFSET, "EST",
            Calendar.MARCH, 2, Calendar.SUNDAY, 7200000, SimpleTimeZone.STANDARD_TIME,
            Calendar.NOVEMBER, 1, Calendar.SUNDAY, 3600000, SimpleTimeZone.STANDARD_TIME,
            3600000);

    checkDstNewYork2014(timeZone);
}
 
源代码17 项目: litchi   文件: DateUtils.java
public static long getWeekMonday0AM(long time) {
	Calendar calendar = getCalendar();
	calendar.setTimeInMillis(time);
	if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
		calendar.add(Calendar.DAY_OF_WEEK, -1);
	}
	calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
	calendar.set(Calendar.HOUR_OF_DAY, 0);
	calendar.set(Calendar.MINUTE, 0);
	calendar.set(Calendar.SECOND, 0);
	calendar.set(Calendar.MILLISECOND, 0);
	return calendar.getTimeInMillis();
}
 
源代码18 项目: xDrip   文件: TimeMessage.java
private static byte dayOfWeekToRawBytes(Calendar cal) {
    int calValue = cal.get(Calendar.DAY_OF_WEEK);
    switch (calValue) {
        case Calendar.SUNDAY:
            return 7;
        default:
            return (byte) (calValue - 1);
    }
}
 
源代码19 项目: openjdk-jdk9   文件: DateTimeTextProvider.java
/**
 * Gets the text for the specified chrono, field, locale and style
 * for the purpose of formatting.
 * <p>
 * The text associated with the value is returned.
 * The null return value should be used if there is no applicable text, or
 * if the text would be a numeric representation of the value.
 *
 * @param chrono  the Chronology to get text for, not null
 * @param field  the field to get text for, not null
 * @param value  the field value to get text for, not null
 * @param style  the style to get text for, not null
 * @param locale  the locale to get text for, not null
 * @return the text for the field value, null if no text found
 */
public String getText(Chronology chrono, TemporalField field, long value,
                                TextStyle style, Locale locale) {
    if (chrono == IsoChronology.INSTANCE
            || !(field instanceof ChronoField)) {
        return getText(field, value, style, locale);
    }

    int fieldIndex;
    int fieldValue;
    if (field == ERA) {
        fieldIndex = Calendar.ERA;
        if (chrono == JapaneseChronology.INSTANCE) {
            if (value == -999) {
                fieldValue = 0;
            } else {
                fieldValue = (int) value + 2;
            }
        } else {
            fieldValue = (int) value;
        }
    } else if (field == MONTH_OF_YEAR) {
        fieldIndex = Calendar.MONTH;
        fieldValue = (int) value - 1;
    } else if (field == DAY_OF_WEEK) {
        fieldIndex = Calendar.DAY_OF_WEEK;
        fieldValue = (int) value + 1;
        if (fieldValue > 7) {
            fieldValue = Calendar.SUNDAY;
        }
    } else if (field == AMPM_OF_DAY) {
        fieldIndex = Calendar.AM_PM;
        fieldValue = (int) value;
    } else {
        return null;
    }
    return CalendarDataUtility.retrieveJavaTimeFieldValueName(
            chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale);
}
 
源代码20 项目: sakai   文件: AddSectionsBean.java
public String getSunday() {
    return daysOfWeek[Calendar.SUNDAY];
}