本文整理汇总了Java中com.google.ical.values.WeekdayNum类的典型用法代码示例。如果您正苦于以下问题:Java WeekdayNum类的具体用法?Java WeekdayNum怎么用?Java WeekdayNum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WeekdayNum类属于com.google.ical.values包,在下文中一共展示了WeekdayNum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleWeeklyRepeatAfterComplete
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
private static long handleWeeklyRepeatAfterComplete(RRule rrule, DateTime original,
boolean hasDueTime) {
List<WeekdayNum> byDay = rrule.getByDay();
long newDate = original.getMillis();
newDate += DateUtilities.ONE_WEEK * (rrule.getInterval() - 1);
DateTime date = new DateTime(newDate);
Collections.sort(byDay, weekdayCompare);
WeekdayNum next = findNextWeekday(byDay, date);
do {
date = date.plusDays(1);
} while (date.getDayOfWeek() != next.wday.javaDayNum);
long time = date.getMillis();
if(hasDueTime) {
return Task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME, time);
} else {
return Task.createDueDate(Task.URGENCY_SPECIFIC_DAY, time);
}
}
示例2: isSelected
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
private boolean isSelected(Weekday day, List<WeekdayNum> days) {
for (WeekdayNum num : days) {
if (num.wday.equals(day)) {
return true;
}
}
return false;
}
示例3: testByDayGenerator
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
public void testByDayGenerator() throws Exception {
WeekdayNum[] days = new WeekdayNum[]{
new WeekdayNum(0, Weekday.SU), // every sunday
new WeekdayNum(1, Weekday.MO), // first monday
new WeekdayNum(5, Weekday.MO), // fifth monday
new WeekdayNum(-2, Weekday.TU) // second to last tuesday
};
Generator g = Generators.byDayGenerator(
days, false, IcalParseUtil.parseDateValue("20060101"));
runGeneratorTests(
g, new DTBuilder(2006, 1, 1), "day", "1, 2, 8, 15, 22, 24, 29, 30");
runGeneratorTests(
g, new DTBuilder(2006, 2, 1), "day", "5, 6, 12, 19, 21, 26");
}
示例4: monkeySeeWeekdayNumList
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
WeekdayNum[] monkeySeeWeekdayNumList(Frequency freq) {
int numRange;
switch (freq) {
case WEEKLY:
numRange = 0;
break;
case MONTHLY:
numRange = 5;
break;
case YEARLY:
numRange = 53;
break;
default:
numRange = 0;
break;
}
int n = 1 + (int) (Math.abs(rnd.nextGaussian() * 2));
WeekdayNum[] wdays = new WeekdayNum[n];
for (int i = n; --i >= 0; ) {
int num = numRange != 0 && rnd.nextInt(10) < 2
? rnd.nextInt(numRange)
: 0;
Weekday wday = WDAYS[rnd.nextInt(7)];
wdays[i] = new WeekdayNum(num, wday);
}
return wdays;
}
示例5: findNextWeekday
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
private static WeekdayNum findNextWeekday(List<WeekdayNum> byDay, DateTime date) {
WeekdayNum next = byDay.get(0);
for (WeekdayNum weekday : byDay) {
if (weekday.wday.javaDayNum > date.getDayOfWeek()) {
return weekday;
}
}
return next;
}
示例6: testAdvancedWeeklyFromDueDate
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
private void testAdvancedWeeklyFromDueDate(boolean completeBefore, String title) {
RRule rrule = new RRule();
rrule.setFreq(Frequency.WEEKLY);
int interval = 1;
rrule.setInterval(interval);
List<WeekdayNum> weekdays = new ArrayList<>();
weekdays.add(new WeekdayNum(0, Weekday.MO));
weekdays.add(new WeekdayNum(0, Weekday.WE));
rrule.setByDay(weekdays);
testRepeating(completeBefore, false, rrule, Frequency.WEEKLY, title);
}
示例7: testAdvancedWeeklyFromCompleteDate
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
private void testAdvancedWeeklyFromCompleteDate(boolean completeBefore, String title) {
RRule rrule = new RRule();
rrule.setFreq(Frequency.WEEKLY);
int interval = 1;
rrule.setInterval(interval);
List<WeekdayNum> weekdays = new ArrayList<>();
weekdays.add(new WeekdayNum(0, Weekday.MO));
weekdays.add(new WeekdayNum(0, Weekday.WE));
rrule.setByDay(weekdays);
testRepeating(completeBefore, true, rrule, Frequency.WEEKLY, title);
}
示例8: setDays
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
public void setDays(boolean[] days) {
List<WeekdayNum> byDay = new ArrayList<>();
if (days != null) {
for (int i = 0; i < days.length; i++) {
if (days[i]) {
byDay.add(new WeekdayNum(0, WEEK_DAYS[i]));
}
}
}
rrule.setByDay(byDay);
// invalidate cached value
this.days = null;
}
示例9: getDays
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
public boolean[] getDays() {
if (this.days == null) {
this.days = new boolean[7];
for (WeekdayNum w : rrule.getByDay()) {
this.days[JAVA_DAY_INDEXES[w.wday.javaDayNum]] = true;
}
}
return this.days;
}
示例10: updateView
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
private void updateView() {
try {
String rule = getSkinnable().getRecurrenceRule();
if (rule == null) {
return;
}
RRule rrule = new RRule(rule);
switch (rrule.getFreq()) {
case DAILY:
frequencyBox.setValue(Frequency.DAILY);
repeatCountGranularity.setText(Messages.getString("RecurrenceViewSkin.DAYS")); //$NON-NLS-1$
break;
case WEEKLY:
frequencyBox.setValue(Frequency.WEEKLY);
repeatCountGranularity.setText(Messages.getString("RecurrenceViewSkin.32")); //$NON-NLS-1$
break;
case MONTHLY:
frequencyBox.setValue(Frequency.MONTHLY);
repeatCountGranularity.setText(Messages.getString("RecurrenceViewSkin.MONTHS")); //$NON-NLS-1$
break;
case YEARLY:
frequencyBox.setValue(Frequency.YEARLY);
repeatCountGranularity.setText(Messages.getString("RecurrenceViewSkin.YEARS")); //$NON-NLS-1$
break;
case SECONDLY:
case HOURLY:
case MINUTELY:
throw new IllegalArgumentException(
"unsupported frequency: " + rrule.getFreq()); //$NON-NLS-1$
default:
throw new IllegalArgumentException(
"unknown frequency: " + rrule.getFreq()); //$NON-NLS-1$
}
DateValue until = rrule.getUntil();
if (until != null) {
endsOnButton.setSelected(true);
endsOnDatePicker.setValue(
LocalDate.of(until.year(), until.month(), until.day()));
} else if (rrule.getCount() > 0) {
endsAfterButton.setSelected(true);
} else {
endsNeverButton.setSelected(true);
}
if (rrule.getByMonthDay().length > 0) {
repeatByDayOfTheMonth.setSelected(true);
} else {
repeatByDayOfTheWeek.setSelected(true);
}
repeatCountSpinnerValueFactory.setValue(rrule.getInterval());
endsAfterCounterSpinnerValueFactory.setValue(rrule.getCount());
List<WeekdayNum> days = rrule.getByDay();
weekDayMondayButton.setSelected(isSelected(Weekday.MO, days));
weekDayTuesdayButton.setSelected(isSelected(Weekday.TU, days));
weekDayWednesdayButton.setSelected(isSelected(Weekday.WE, days));
weekDayThursdayButton.setSelected(isSelected(Weekday.TH, days));
weekDayFridayButton.setSelected(isSelected(Weekday.FR, days));
weekDaySaturdayButton.setSelected(isSelected(Weekday.SA, days));
weekDaySundayButton.setSelected(isSelected(Weekday.SU, days));
summary.setText(Util.convertRFC2445ToText(rule,
getSkinnable().getStartDate()));
} catch (ParseException e) {
e.printStackTrace();
}
startOnDateLabel
.setText(DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG)
.format(getSkinnable().getStartDate()));
}
示例11: maybeAddWeekday
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
private void maybeAddWeekday(List<WeekdayNum> weekdays,
WeekdayNum weekdayNum, ToggleButton button) {
if (button.isSelected()) {
weekdays.add(weekdayNum);
}
}
示例12: testInvertWeekdayNum
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
public void testInvertWeekdayNum() throws Exception {
// January 2006
// # Su Mo Tu We Th Fr Sa
// 1 1 2 3 4 5 6 7
// 2 8 9 10 11 12 13 14
// 3 15 16 17 18 19 20 21
// 4 22 23 24 25 26 27 28
// 5 29 30 31
// the 1st falls on a sunday, so dow0 == SU
assertEquals(
5,
Util.invertWeekdayNum(new WeekdayNum(-1, Weekday.SU), Weekday.SU, 31));
assertEquals(
5,
Util.invertWeekdayNum(new WeekdayNum(-1, Weekday.MO), Weekday.SU, 31));
assertEquals(
5,
Util.invertWeekdayNum(new WeekdayNum(-1, Weekday.TU), Weekday.SU, 31));
assertEquals(
4,
Util.invertWeekdayNum(new WeekdayNum(-1, Weekday.WE), Weekday.SU, 31));
assertEquals(
3,
Util.invertWeekdayNum(new WeekdayNum(-2, Weekday.WE), Weekday.SU, 31));
// February 2006
// # Su Mo Tu We Th Fr Sa
// 1 1 2 3 4
// 2 5 6 7 8 9 10 11
// 3 12 13 14 15 16 17 18
// 4 19 20 21 22 23 24 25
// 5 26 27 28
assertEquals(
4,
Util.invertWeekdayNum(new WeekdayNum(-1, Weekday.SU), Weekday.WE, 28));
assertEquals(
4,
Util.invertWeekdayNum(new WeekdayNum(-1, Weekday.MO), Weekday.WE, 28));
assertEquals(
4,
Util.invertWeekdayNum(new WeekdayNum(-1, Weekday.TU), Weekday.WE, 28));
assertEquals(
4,
Util.invertWeekdayNum(new WeekdayNum(-1, Weekday.WE), Weekday.WE, 28));
assertEquals(
3,
Util.invertWeekdayNum(new WeekdayNum(-2, Weekday.WE), Weekday.WE, 28));
}
示例13: compare
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
@Override
public int compare(WeekdayNum object1, WeekdayNum object2) {
return object1.wday.javaDayNum - object2.wday.javaDayNum;
}
示例14: getRecurrence
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
private String getRecurrence() {
String result;
if(!doRepeat) {
result = ""; //$NON-NLS-1$
} else {
RRule rrule = new RRule();
rrule.setInterval(repeatValue);
switch(intervalValue) {
case INTERVAL_DAYS:
rrule.setFreq(Frequency.DAILY);
break;
case INTERVAL_WEEKS: {
rrule.setFreq(Frequency.WEEKLY);
ArrayList<WeekdayNum> days = new ArrayList<>();
for (int i = 0 ; i < isChecked.length ; i++) {
if (isChecked[i]) {
days.add(new WeekdayNum(0, weekdays[i]));
}
}
rrule.setByDay(days);
break;
}
case INTERVAL_MONTHS:
rrule.setFreq(Frequency.MONTHLY);
break;
case INTERVAL_HOURS:
rrule.setFreq(Frequency.HOURLY);
break;
case INTERVAL_MINUTES:
rrule.setFreq(Frequency.MINUTELY);
break;
case INTERVAL_YEARS:
rrule.setFreq(Frequency.YEARLY);
break;
}
result = rrule.toIcal();
}
return result;
}
示例15: setRRuleDays
import com.google.ical.values.WeekdayNum; //导入依赖的package包/类
private void setRRuleDays(RRule rrule, Weekday... weekdays) {
ArrayList<WeekdayNum> days = new ArrayList<>();
for(Weekday wd : weekdays)
days.add(new WeekdayNum(0, wd));
rrule.setByDay(days);
}