当前位置: 首页>>代码示例>>Java>>正文


Java Weeks.getWeeks方法代码示例

本文整理汇总了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;
}
 
开发者ID:ViDA-NYU,项目名称:data-polygamy,代码行数:39,代码来源:FrameworkUtils.java

示例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];
}
 
开发者ID:suaree,项目名称:eventbrite4j,代码行数:15,代码来源:WeeklySchedule.java

示例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);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:13,代码来源:WeeksBetweenDates.java


注:本文中的org.joda.time.Weeks.getWeeks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。