本文整理汇总了Java中org.threeten.bp.LocalDate.of方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDate.of方法的具体用法?Java LocalDate.of怎么用?Java LocalDate.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threeten.bp.LocalDate
的用法示例。
在下文中一共展示了LocalDate.of方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: should_restore_from_parcelable
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
@Test
public void should_restore_from_parcelable() {
// Given
LocalDate day = LocalDate.of(1985, 5, 15);
List<ScheduleSlot> slots = singletonList(new ScheduleSlot(null, null));
ScheduleDay scheduleDay = new ScheduleDay(day, slots);
// When
Parcel parcel = Parcel.obtain();
scheduleDay.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
ScheduleDay fromParcel = ScheduleDay.CREATOR.createFromParcel(parcel);
// Then
assertThat(fromParcel.getDay()).isEqualTo(day);
assertThat(fromParcel.getSlots()).hasSize(1);
}
示例2: createDialog
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
/**
* Creates a {@link DatePickerDialog} instance with the <code>localDate</code> selected.
*
* @param localDate the selected start localDate
* @param listener to be triggered when the user selects a localDate
* @param clock to get the current date
* @return the {@link DatePickerDialog} created instance
*/
@NonNull
public static DatePickerDialog createDialog(@Nullable LocalDate localDate, @Nullable Consumer<LocalDate> listener,
@NonNull Clock clock) {
localDate = Optional.ofNullable(localDate)
.orElse(LocalDate.now(clock));
DatePickerDialog.OnDateSetListener dialogCallBack = (view, year, monthOfYear, dayOfMonth) -> {
LocalDate date = LocalDate.of(year, monthOfYear + 1, dayOfMonth);
Optional.ofNullable(listener)
.ifPresent(theListener -> theListener.accept(date));
};
DatePickerDialog datePickerDialog = DatePickerDialog.newInstance(
dialogCallBack,
localDate.getYear(),
localDate.getMonthValue() - 1,
localDate.getDayOfMonth()
);
datePickerDialog.dismissOnPause(true);
return datePickerDialog;
}
示例3: generates_single_password_if_date_interval_just_one_date
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
@Test
public void generates_single_password_if_date_interval_just_one_date() {
LocalDate d1 = LocalDate.of(2016, 1, 5);
LocalDate d2 = LocalDate.of(2016, 1, 5);
Map<LocalDate, String> potd_list = Arrispwgen.generate_multi(d1, d2, DEFAULT_SEED);
assertEquals(1, potd_list.size());
}
示例4: localDateToCalendarDay
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
@Test
public void localDateToCalendarDay() {
LocalDate localDate = LocalDate.of(2016, 11, 15);
CalendarDay expectedCalendarDay = CalendarDay.from(2016, 10, 15);
CalendarDay actualCalendarDay = DateHelper.localDateToCalendarDay(localDate);
assertEquals(expectedCalendarDay, actualCalendarDay);
}
示例5: calendarDayToLocalDate
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
@Test
public void calendarDayToLocalDate() {
CalendarDay calendarDay = CalendarDay.from(2016, 10, 15);
LocalDate expectedLocalDate = LocalDate.of(2016, 11, 15);
LocalDate actualLocalDate = DateHelper.calendarDayToLocalDate(calendarDay);
assertEquals(expectedLocalDate, actualLocalDate);
}
示例6: getFirstDayOfWeekThursday
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
@Test
public void getFirstDayOfWeekThursday() {
LocalDate thursday = LocalDate.of(2017, Month.APRIL, 13);
LocalDate actualMonday = DateHelper.getFirstDayOfWeek(thursday);
assertThat(actualMonday, equalTo(LOCAL_DATE_MONDAY_10TH_APR_2017));
}
示例7: getFirstDayOfWeekPreviousWeek
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
@Test
public void getFirstDayOfWeekPreviousWeek() {
LocalDate thursday = LocalDate.of(2017, Month.APRIL, 9);
LocalDate actualMonday = DateHelper.getFirstDayOfWeek(thursday);
assertThat(actualMonday, not(equalTo(LOCAL_DATE_MONDAY_10TH_APR_2017)));
}
示例8: getFirstDayOfWeekNextWeek
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
@Test
public void getFirstDayOfWeekNextWeek() {
LocalDate tuesdayNext = LocalDate.of(2017, Month.APRIL, 18);
LocalDate actualMonday = DateHelper.getFirstDayOfWeek(tuesdayNext);
assertThat(actualMonday, not(equalTo(LOCAL_DATE_MONDAY_10TH_APR_2017)));
}
示例9: set_start_date
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
public void set_start_date(int year, int month, int dayOfMonth) {
start_date = LocalDate.of(year, month, dayOfMonth);
}
示例10: set_end_date
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
public void set_end_date(int year, int month, int dayOfMonth) {
end_date = LocalDate.of(year, month, dayOfMonth);
}
示例11: throws_exception_if_start_date_after_end_date
import org.threeten.bp.LocalDate; //导入方法依赖的package包/类
@Test(expected=IllegalArgumentException.class)
public void throws_exception_if_start_date_after_end_date() {
LocalDate d1 = LocalDate.of(2016, 1, 10);
LocalDate d2 = LocalDate.of(2016, 1, 5);
Arrispwgen.generate_multi(d1, d2, DEFAULT_SEED);
}