本文整理了Java中org.activityinfo.model.type.time.LocalDate.getDayOfYear()
方法的一些代码示例,展示了LocalDate.getDayOfYear()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.getDayOfYear()
方法的具体详情如下:
包路径:org.activityinfo.model.type.time.LocalDate
类名称:LocalDate
方法名:getDayOfYear
暂无
代码示例来源:origin: bedatadriven/activityinfo
public static int daysBetween(LocalDate x, LocalDate y) {
assert !x.after(y);
int days = -x.getDayOfYear();
int year = x.getYear();
while(year < y.getYear()) {
if(YearValue.isLeapYear(year)) {
days += 366;
} else {
days += 365;
}
year++;
}
return days + y.getDayOfYear();
}
代码示例来源:origin: bedatadriven/activityinfo
@Test
public void dayOfYear() {
// non leap year
assertThat(new LocalDate(2017, 1, 1).getDayOfYear(), equalTo(1));
assertThat(new LocalDate(2017, 2, 1).getDayOfYear(), equalTo(32));
assertThat(new LocalDate(2017, 2, 10).getDayOfYear(), equalTo(41));
assertThat(new LocalDate(2017, 3, 4).getDayOfYear(), equalTo(63));
assertThat(new LocalDate(2017, 7, 13).getDayOfYear(), equalTo(194));
assertThat(new LocalDate(2017, 12, 31).getDayOfYear(), equalTo(365));
// leap year
assertThat(new LocalDate(2004, 1, 1).getDayOfYear(), equalTo(1));
assertThat(new LocalDate(2004, 2, 1).getDayOfYear(), equalTo(32));
assertThat(new LocalDate(2004, 2, 10).getDayOfYear(), equalTo(41));
assertThat(new LocalDate(2004, 3, 4).getDayOfYear(), equalTo(64));
assertThat(new LocalDate(2004, 7, 13).getDayOfYear(), equalTo(195));
assertThat(new LocalDate(2004, 12, 31).getDayOfYear(), equalTo(366));
}
内容来源于网络,如有侵权,请联系作者删除!