/** * @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); }
@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 ); }
/** * 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(); }
@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(); }
@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()); }
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); }
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); }
@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)); }
@Override // override with covariant return type public JapaneseDate date(int prolepticYear, int month, int dayOfMonth) { return new JapaneseDate(LocalDate.of(prolepticYear, month, dayOfMonth)); }
@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)); }
@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)); }
@Override // override with covariant return type public JapaneseDate date(int prolepticYear, int month, int dayOfMonth) { return new JapaneseDate(LocalDate.of(prolepticYear, month, dayOfMonth)); }
/** * 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()); }
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; } } }
/** * 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()); }
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; }
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; }
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; } } }
@Override public LocalDate convert(com.datastax.driver.core.LocalDate source) { return LocalDate.of(source.getYear(), source.getMonth(), source.getDay()); } }
@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); }