本文整理汇总了Java中java.util.Calendar.SUNDAY属性的典型用法代码示例。如果您正苦于以下问题:Java Calendar.SUNDAY属性的具体用法?Java Calendar.SUNDAY怎么用?Java Calendar.SUNDAY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.Calendar
的用法示例。
在下文中一共展示了Calendar.SUNDAY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDay
private int getDay(int day) {
switch (day) {
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;
}
}
示例2: getDays
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;
}
示例3: getDayOfWeek
public static int getDayOfWeek(Date date) {
Calendar c = Calendar.getInstance(Locale.US);
c.setTime(date);
switch (c.get(Calendar.DAY_OF_WEEK)) {
case Calendar.MONDAY:
return DAY_MON;
case Calendar.TUESDAY:
return DAY_TUE;
case Calendar.WEDNESDAY:
return DAY_WED;
case Calendar.THURSDAY:
return DAY_THU;
case Calendar.FRIDAY:
return DAY_FRI;
case Calendar.SATURDAY:
return DAY_SAT;
case Calendar.SUNDAY:
return DAY_SUN;
default:
return DAY_MON;
}
}
示例4: getTextView
/**
* Get text view regarding a date
* @param date date
* @return text view
*/
private int getTextView(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
switch (calendar.get(Calendar.DAY_OF_WEEK)) {
case Calendar.MONDAY:
return R.id.monday_open_time;
case Calendar.TUESDAY:
return R.id.tuesday_open_time;
case Calendar.WEDNESDAY:
return R.id.wednesday_open_time;
case Calendar.THURSDAY:
return R.id.thursday_open_time;
case Calendar.FRIDAY:
return R.id.friday_open_time;
case Calendar.SATURDAY:
return R.id.saturday_open_time;
case Calendar.SUNDAY:
return R.id.sunday_open_time;
}
return 0;
}
示例5: getDayOfWeek
/**
* 描述:获取本周的某一天.
*
* @param format the format
* @param calendarField the calendar field
* @return String String类型日期时间
*/
private static String getDayOfWeek(String format, int calendarField) {
String strDate = null;
try {
Calendar c = new GregorianCalendar();
SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format);
int week = c.get(Calendar.DAY_OF_WEEK);
if (week == calendarField) {
strDate = mSimpleDateFormat.format(c.getTime());
} else {
int offectDay = calendarField - week;
if (calendarField == Calendar.SUNDAY) {
offectDay = 7 - Math.abs(offectDay);
}
c.add(Calendar.DATE, offectDay);
strDate = mSimpleDateFormat.format(c.getTime());
}
} catch (Exception e) {
e.printStackTrace();
}
return strDate;
}
示例6: parseViewIdToDayOfWeek
public static int parseViewIdToDayOfWeek(Integer viewId) {
switch (viewId) {
case R.id.monday_date_picker:
return Calendar.MONDAY;
case R.id.tuesday_date_picker:
return Calendar.TUESDAY;
case R.id.wednesday_date_picker:
return Calendar.WEDNESDAY;
case R.id.thursday_date_picker:
return Calendar.THURSDAY;
case R.id.friday_date_picker:
return Calendar.FRIDAY;
case R.id.saturday_date_picker:
return Calendar.SATURDAY;
case R.id.sunday_date_picker:
return Calendar.SUNDAY;
default:
return 0;
}
}
示例7: checkWorkday
@Override
protected boolean checkWorkday(Calendar cal) {
Calendar dayBefore = new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
dayBefore.add(Calendar.DATE, -1);
Calendar dayAfter = new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
dayAfter.add(Calendar.DATE, 1);
// if day before cal is a holiday and the day after cal is saturday
// then cal is a bridge day (means: no work day)
if(this.holidayProvider.isHoliday(dayBefore) && dayAfter.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
return false;
}
// if day before cal is a sunday and the day after cal is a holiday
// then cal is a bridge day (means: no work day)
if(dayBefore.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY && this.holidayProvider.isHoliday(dayAfter)) {
return false;
}
return true;
}
示例8: toWeekDay
private static int toWeekDay(int calWeekDay) {
if (calWeekDay == Calendar.SUNDAY) {
return 7;
} else {
return calWeekDay - 1;
}
}
示例9: getWeekDay
/**
* 根据日期,返回其星期数,周一为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: WeekLesson
/**
* Full params constructor
*/
public WeekLesson(int week_lesson_id, @Nonnull String subject_id, int repeat_id, @Nonnegative int week_lesson_day_start,
@Nonnegative int week_lesson_day_end, @Nonnegative int week_lesson_day_index) {
if (week_lesson_id > 0) {
this.week_lesson_id = week_lesson_id;
} else {
this.week_lesson_id = Constant.INT_NONE_VALUE;
}
this.subject_id = subject_id;
if (repeat_id > 0) {
this.repeat_id = repeat_id;
} else {
this.repeat_id = Constant.INT_NONE_VALUE;
}
if (week_lesson_day_start >= 0) {
this.week_lesson_day_start = week_lesson_day_start;
}else {
this.week_lesson_day_start = 0;
}
if (!(week_lesson_day_end >= this.week_lesson_day_start)) {
this.week_lesson_day_end = week_lesson_day_end;
}else {
this.week_lesson_day_end = this.week_lesson_day_start;
}
if (week_lesson_day_index >= Calendar.SUNDAY && week_lesson_day_index <= Calendar.SATURDAY) {
this.week_lesson_day_index = week_lesson_day_index;
}
}
示例11: exactTime256WithUpdateReason
static byte[] exactTime256WithUpdateReason(Calendar time, byte updateReason) {
// See https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.current_time.xml
// Calendar: January = 0
// CTS: January = 1
int month = time.get(Calendar.MONTH) + 1;
// Calendar: Monday = 2, Sunday = 1
// CTS: Monday = 1, Sunday = 7
int dayOfWeek = time.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == Calendar.SUNDAY) {
dayOfWeek = 7;
} else {
dayOfWeek = dayOfWeek - 1;
}
// 256ths of a second
int fractionsOfSecond = (int)((time).get(Calendar.MILLISECOND) * 0.255F);
return ByteBuffer.allocate(10)
.order(ByteOrder.LITTLE_ENDIAN)
.putShort((short) time.get(Calendar.YEAR))
.put((byte) month)
.put((byte) time.get(Calendar.DAY_OF_MONTH))
.put((byte) time.get(Calendar.HOUR_OF_DAY))
.put((byte) time.get(Calendar.MINUTE))
.put((byte) time.get(Calendar.SECOND))
.put((byte) dayOfWeek)
.put((byte) fractionsOfSecond)
.put(updateReason)
.array();
}
示例12: setFirstDayOfWeek
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();
}
}
示例13: getValueAt
public Object getValueAt(int row, int col) {
Event ev = getEventAt(row,col);
if(ev == null) return "";
Calendar cal = (Calendar)days[col].get(row);
String res = "";
switch(cal.get(Calendar.DAY_OF_WEEK)){
case Calendar.SUNDAY: res += "SU";
break;
case Calendar.MONDAY: res += "MO";
break;
case Calendar.TUESDAY: res += "TU";
break;
case Calendar.WEDNESDAY: res += "WE";
break;
case Calendar.THURSDAY: res += "TH";
break;
case Calendar.FRIDAY: res += "FR";
break;
case Calendar.SATURDAY: res += "SA";
break;
default: res += "??";
}
String dOM = cal.get(Calendar.DAY_OF_MONTH) + "";
switch(cal.get(Calendar.DAY_OF_MONTH)%10){
case 1: dOM += "st";
break;
case 2: dOM += "nd";
break;
case 3: dOM += "rd";
break;
default:dOM+="th";
}
res+= " / " + dOM + ": ";
if(ev.getText().equals("")) res+= "EVENT";
else res += ev.getText();
return res;
}
示例14: checkCurrentTime
private void checkCurrentTime() {
Calendar now = Calendar.getInstance();
int second = now.get(Calendar.SECOND);
int minute = now.get(Calendar.MINUTE);
int hour = now.get(Calendar.HOUR_OF_DAY);
int weekday = now.get(Calendar.DAY_OF_WEEK);
boolean isWeekend = weekday == Calendar.SUNDAY || weekday == Calendar.SATURDAY;
_logger.Debug(String.format(Locale.GERMAN,
"checkCurrentTime at %02d:%02d:%02d on %d",
hour, minute, second, weekday));
if ((second >= 0 && second < 5) && minute == 0) {
for (AutomaticSettings entry : AutomaticSettings.values()) {
if (entry.GetEnableHour() == hour) {
if ((entry.IsWeekend() && isWeekend) || (!entry.IsWeekend() && !isWeekend)) {
int maxVolume = _mediaVolumeController.GetMaxVolume();
double currentVolume = (entry.GetSoundVolumePercentage() / 100) * maxVolume;
setSettings(currentVolume, (int) entry.GetScreenBrightnessPercentage());
break;
}
}
}
}
}
示例15: RepeatPreference
public RepeatPreference(Context context, AttributeSet attrs) {
super(context, attrs);
String[] weekdays = new DateFormatSymbols().getWeekdays();
String[] values = new String[]{
weekdays[Calendar.MONDAY],
weekdays[Calendar.TUESDAY],
weekdays[Calendar.WEDNESDAY],
weekdays[Calendar.THURSDAY],
weekdays[Calendar.FRIDAY],
weekdays[Calendar.SATURDAY],
weekdays[Calendar.SUNDAY],};
setEntries(values);
setEntryValues(values);
}