本文整理了Java中org.threeten.bp.LocalDate.of()
方法的一些代码示例,展示了LocalDate.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.of()
方法的具体详情如下:
包路径:org.threeten.bp.LocalDate
类名称:LocalDate
方法名:of
[英]Obtains an instance of LocalDate from a year, month and day.
The day must be valid for the year and month, otherwise an exception will be thrown.
[中]从年、月和日获取LocalDate的实例。
日期必须对年和月有效,否则将引发异常。
代码示例来源:origin: prolificinteractive/material-calendarview
/**
* @param year new instance's year
* @param month new instance's month as defined by {@linkplain java.util.Calendar}
* @param day new instance's day of month
*/
private CalendarDay(final int year, final int month, final int day) {
date = LocalDate.of(year, month, day);
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_basic_modes);
ButterKnife.bind(this);
widget.setOnDateChangedListener(this);
widget.setShowOtherDates(MaterialCalendarView.SHOW_ALL);
final LocalDate instance = LocalDate.now();
widget.setSelectedDate(instance);
final LocalDate min = LocalDate.of(instance.getYear(), Month.JANUARY, 1);
final LocalDate max = LocalDate.of(instance.getYear(), Month.DECEMBER, 31);
widget.state().edit().setMinimumDate(min).setMaximumDate(max).commit();
widget.addDecorators(
new MySelectorDecorator(this),
new HighlightWeekendsDecorator(),
oneDayDecorator
);
}
代码示例来源:origin: prolificinteractive/material-calendarview
/**
* Clear the previous selection, select the range of days from first to last, and finally
* invalidate. First day should be before last day, otherwise the selection won't happen.
*
* @param first The first day of the range.
* @param last The last day in the range.
* @see CalendarPagerAdapter#setDateSelected(CalendarDay, boolean)
*/
public void selectRange(final CalendarDay first, final CalendarDay last) {
selectedDates.clear();
// Copy to start from the first day and increment
LocalDate temp = LocalDate.of(first.getYear(), first.getMonth(), first.getDay());
// for comparison
final LocalDate end = last.getDate();
while( temp.isBefore(end) || temp.equals(end) ) {
selectedDates.add(CalendarDay.from(temp));
temp = temp.plusDays(1);
}
invalidateSelectedDates();
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_basic);
ButterKnife.bind(this);
// Add a decorator to disable prime numbered days
widget.addDecorator(new PrimeDayDisableDecorator());
// Add a second decorator that explicitly enables days <= 10. This will work because
// decorators are applied in order, and the system allows re-enabling
widget.addDecorator(new EnableOneToTenDecorator());
final LocalDate calendar = LocalDate.now();
widget.setSelectedDate(calendar);
final LocalDate min = LocalDate.of(calendar.getYear(), Month.JANUARY, 1);
final LocalDate max = LocalDate.of(calendar.getYear() + 1, Month.OCTOBER, 31);
widget.state().edit()
.setMinimumDate(min)
.setMaximumDate(max)
.commit();
}
代码示例来源:origin: prolificinteractive/material-calendarview
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_basic);
ButterKnife.bind(this);
widget.setOnDateChangedListener(this);
widget.setShowOtherDates(MaterialCalendarView.SHOW_ALL);
final LocalDate instance = LocalDate.now();
widget.setSelectedDate(instance);
final LocalDate min = LocalDate.of(instance.getYear(), Month.JANUARY, 1);
final LocalDate max = LocalDate.of(instance.getYear(), Month.DECEMBER, 31);
widget.state().edit().setMinimumDate(min).setMaximumDate(max).commit();
widget.addDecorators(
new MySelectorDecorator(this),
new HighlightWeekendsDecorator(),
oneDayDecorator
);
new ApiSimulator().executeOnExecutor(Executors.newSingleThreadExecutor());
}
代码示例来源:origin: ThreeTen/threetenbp
static LocalDate readExternal(DataInput in) throws IOException {
int year = in.readInt();
int month = in.readByte();
int dayOfMonth = in.readByte();
return LocalDate.of(year, month, dayOfMonth);
}
代码示例来源:origin: org.threeten/threetenbp
static LocalDate readExternal(DataInput in) throws IOException {
int year = in.readInt();
int month = in.readByte();
int dayOfMonth = in.readByte();
return LocalDate.of(year, month, dayOfMonth);
}
代码示例来源:origin: ThreeTen/threetenbp
@Override // override with covariant return type
public MinguoDate date(int prolepticYear, int month, int dayOfMonth) {
return new MinguoDate(LocalDate.of(prolepticYear + YEARS_DIFFERENCE, month, dayOfMonth));
}
代码示例来源:origin: ThreeTen/threetenbp
@Override // override with covariant return type
public JapaneseDate date(int prolepticYear, int month, int dayOfMonth) {
return new JapaneseDate(LocalDate.of(prolepticYear, month, dayOfMonth));
}
代码示例来源:origin: ThreeTen/threetenbp
@Override // override with covariant return type
public ThaiBuddhistDate date(int prolepticYear, int month, int dayOfMonth) {
return new ThaiBuddhistDate(LocalDate.of(prolepticYear - YEARS_DIFFERENCE, month, dayOfMonth));
}
代码示例来源:origin: org.threeten/threetenbp
@Override // override with covariant return type
public ThaiBuddhistDate date(int prolepticYear, int month, int dayOfMonth) {
return new ThaiBuddhistDate(LocalDate.of(prolepticYear - YEARS_DIFFERENCE, month, dayOfMonth));
}
代码示例来源:origin: org.threeten/threetenbp
@Override // override with covariant return type
public JapaneseDate date(int prolepticYear, int month, int dayOfMonth) {
return new JapaneseDate(LocalDate.of(prolepticYear, month, dayOfMonth));
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Converts a {@code java.sql.Date} to a {@code LocalDate}.
*
* @param sqlDate the SQL date, not null
* @return the local date, not null
*/
@SuppressWarnings("deprecation")
public static LocalDate toLocalDate(java.sql.Date sqlDate) {
return LocalDate.of(sqlDate.getYear() + 1900, sqlDate.getMonth() + 1, sqlDate.getDate());
}
代码示例来源:origin: org.threeten/threetenbp
void adjustToFowards(int year) {
if (adjustForwards == false && dayOfMonth > 0) {
LocalDate adjustedDate = LocalDate.of(year, month, dayOfMonth).minusDays(6);
dayOfMonth = adjustedDate.getDayOfMonth();
month = adjustedDate.getMonth();
adjustForwards = true;
}
}
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Converts a {@code java.sql.Date} to a {@code LocalDate}.
*
* @param sqlDate the SQL date, not null
* @return the local date, not null
*/
@SuppressWarnings("deprecation")
public static LocalDate toLocalDate(java.sql.Date sqlDate) {
return LocalDate.of(sqlDate.getYear() + 1900, sqlDate.getMonth() + 1, sqlDate.getDate());
}
代码示例来源:origin: ThreeTen/threetenbp
private static int getWeekRange(int wby) {
LocalDate date = LocalDate.of(wby, 1, 1);
// 53 weeks if standard year starts on Thursday, or Wed in a leap year
if (date.getDayOfWeek() == THURSDAY || (date.getDayOfWeek() == WEDNESDAY && date.isLeapYear())) {
return 53;
}
return 52;
}
代码示例来源:origin: org.threeten/threetenbp
private static int getWeekRange(int wby) {
LocalDate date = LocalDate.of(wby, 1, 1);
// 53 weeks if standard year starts on Thursday, or Wed in a leap year
if (date.getDayOfWeek() == THURSDAY || (date.getDayOfWeek() == WEDNESDAY && date.isLeapYear())) {
return 53;
}
return 52;
}
代码示例来源:origin: ThreeTen/threetenbp
void adjustToFowards(int year) {
if (adjustForwards == false && dayOfMonth > 0) {
LocalDate adjustedDate = LocalDate.of(year, month, dayOfMonth).minusDays(6);
dayOfMonth = adjustedDate.getDayOfMonth();
month = adjustedDate.getMonth();
adjustForwards = true;
}
}
}
代码示例来源:origin: org.springframework.data/spring-data-cassandra
@Override
public LocalDate convert(com.datastax.driver.core.LocalDate source) {
return LocalDate.of(source.getYear(), source.getMonth(), source.getDay());
}
}
代码示例来源:origin: jeffdcamp/dbtools-android
@Before
public void setUp() throws Exception {
jsr301DateTime = LocalDateTime.of(1970, Month.MAY, 18, 13, 30, 0, 20000000);
jsr301Date = LocalDate.of(1970, Month.MAY, 18);
jsr301Time = LocalTime.of(13, 30, 0);
jodaDateTime = new DateTime(1970, 5, 18, 13, 30, 0, 20);
jodaDateTimeUtc = new DateTime(1970, 5, 18, 13, 30, 0, 20, DateTimeZone.UTC);
}
内容来源于网络,如有侵权,请联系作者删除!