本文整理汇总了Java中org.joda.time.Weeks.getWeeks方法的典型用法代码示例。如果您正苦于以下问题:Java Weeks.getWeeks方法的具体用法?Java Weeks.getWeeks怎么用?Java Weeks.getWeeks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.Weeks
的用法示例。
在下文中一共展示了Weeks.getWeeks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDeltaSinceEpoch
import org.joda.time.Weeks; //导入方法依赖的package包/类
public static int getDeltaSinceEpoch(int time, int tempRes) {
int delta = 0;
// Epoch
MutableDateTime epoch = new MutableDateTime();
epoch.setDate(0);
DateTime dt = new DateTime(time*1000, DateTimeZone.UTC);
switch(tempRes) {
case FrameworkUtils.HOUR:
Hours hours = Hours.hoursBetween(epoch, dt);
delta = hours.getHours();
break;
case FrameworkUtils.DAY:
Days days = Days.daysBetween(epoch, dt);
delta = days.getDays();
break;
case FrameworkUtils.WEEK:
Weeks weeks = Weeks.weeksBetween(epoch, dt);
delta = weeks.getWeeks();
break;
case FrameworkUtils.MONTH:
Months months = Months.monthsBetween(epoch, dt);
delta = months.getMonths();
break;
case FrameworkUtils.YEAR:
Years years = Years.yearsBetween(epoch, dt);
delta = years.getYears();
break;
default:
hours = Hours.hoursBetween(epoch, dt);
delta = hours.getHours();
break;
}
return delta;
}
示例2: matchesSchedule
import org.joda.time.Weeks; //导入方法依赖的package包/类
private boolean matchesSchedule(Calendar firstDate, Calendar testDate) {
DateMidnight dmFirst = new DateMidnight(firstDate.getTimeInMillis());
DateMidnight dmTest = new DateMidnight(testDate.getTimeInMillis());
Weeks weeks = Weeks.weeksBetween(dmFirst, dmTest);
if (0 != weeks.getWeeks() % frequency) {
return false;
}
int dow = testDate.get(Calendar.DAY_OF_WEEK);
int dayIndex = ((dow - Calendar.SUNDAY) + 6) % 7;
return occurrs[dayIndex];
}
示例3: weeks_between_two_dates_in_java_with_joda
import org.joda.time.Weeks; //导入方法依赖的package包/类
@Test
public void weeks_between_two_dates_in_java_with_joda () {
DateTime start = new DateTime(2005, 1, 1, 0, 0, 0, 0);
DateTime end = new DateTime(2006, 1, 1, 0, 0, 0, 0);
Weeks weeks = Weeks.weeksBetween(start, end);
int weeksInYear = weeks.getWeeks();
assertEquals(52, weeksInYear);
}