/** * Get a new instance set to today * * @return CalendarDay set to today's date */ @NonNull public static CalendarDay today() { return from(LocalDate.now()); }
@Override public void onBindViewHolder(EntryViewHolder holder, int position) { //set selected date to today holder.calendarView.setSelectedDate(LocalDate.now()); }
@Override protected List<CalendarDay> doInBackground(@NonNull Void... voids) { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } LocalDate temp = LocalDate.now().minusMonths(2); final ArrayList<CalendarDay> dates = new ArrayList<>(); for (int i = 0; i < 30; i++) { final CalendarDay day = CalendarDay.from(temp); dates.add(day); temp = temp.plusDays(5); } return dates; }
public StateBuilder() { calendarMode = CalendarMode.MONTHS; firstDayOfWeek = LocalDate.now().with(WeekFields.of(Locale.getDefault()).dayOfWeek(), 1).getDayOfWeek(); }
@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()); }
@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(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 ); }
/** * Obtains the current {@code JapaneseDate} from the specified clock. * <p> * This will query the specified clock to obtain the current date - today. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@linkplain Clock dependency injection}. * * @param clock the clock to use, not null * @return the current date, not null * @throws DateTimeException if the current date cannot be obtained */ public static JapaneseDate now(Clock clock) { return new JapaneseDate(LocalDate.now(clock)); }
/** * Obtains the current date from the system clock in the default time-zone. * <p> * This will query the {@link Clock#systemDefaultZone() system clock} in the default * time-zone to obtain the current date. * <p> * Using this method will prevent the ability to use an alternate clock for testing * because the clock is hard-coded. * * @return the current date using the system clock and default time-zone, not null */ public static LocalDate now() { return now(Clock.systemDefaultZone()); }
/** * Obtains the current {@code MinguoDate} from the specified clock. * <p> * This will query the specified clock to obtain the current date - today. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@linkplain Clock dependency injection}. * * @param clock the clock to use, not null * @return the current date, not null * @throws DateTimeException if the current date cannot be obtained */ public static MinguoDate now(Clock clock) { return new MinguoDate(LocalDate.now(clock)); }
/** * Obtains the current {@code ThaiBuddhistDate} from the specified clock. * <p> * This will query the specified clock to obtain the current date - today. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@linkplain Clock dependency injection}. * * @param clock the clock to use, not null * @return the current date, not null * @throws DateTimeException if the current date cannot be obtained */ public static ThaiBuddhistDate now(Clock clock) { return new ThaiBuddhistDate(LocalDate.now(clock)); }
public boolean isToady(@NonNull LocalDate day) { return LocalDate.now().equals(day); }
/** * Obtains the current date from the system clock in the default time-zone. * <p> * This will query the {@link Clock#systemDefaultZone() system clock} in the default * time-zone to obtain the current date. * <p> * Using this method will prevent the ability to use an alternate clock for testing * because the clock is hard-coded. * * @return the current date using the system clock and default time-zone, not null */ public static LocalDate now() { return now(Clock.systemDefaultZone()); }
public CalendarAdapter(Context context) { this.mCal = LocalDate.now().withDayOfMonth(1); mInflater = LayoutInflater.from(context); refresh(); }
public LocalDate getSelectedDay() { if (getSelectedItem() == null) { return LocalDate.now(); } return getSelectedItem(); }
/** * Obtains the current local date in this chronology from the specified clock. * <p> * This will query the specified clock to obtain the current date - today. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@link Clock dependency injection}. * * @param clock the clock to use, not null * @return the current local date, not null * @throws DateTimeException if unable to create the date */ public ChronoLocalDate dateNow(Clock clock) { Jdk8Methods.requireNonNull(clock, "clock"); return date(LocalDate.now(clock)); }
/** * Obtains the current year from the specified clock. * <p> * This will query the specified clock to obtain the current year. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@link Clock dependency injection}. * * @param clock the clock to use, not null * @return the current year, not null */ public static Year now(Clock clock) { final LocalDate now = LocalDate.now(clock); // called once return Year.of(now.getYear()); }
/** * Obtains the current month-day from the specified clock. * <p> * This will query the specified clock to obtain the current month-day. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@link Clock dependency injection}. * * @param clock the clock to use, not null * @return the current month-day, not null */ public static MonthDay now(Clock clock) { final LocalDate now = LocalDate.now(clock); // called once return MonthDay.of(now.getMonth(), now.getDayOfMonth()); }
/** * Obtains the current month-day from the specified clock. * <p> * This will query the specified clock to obtain the current month-day. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@link Clock dependency injection}. * * @param clock the clock to use, not null * @return the current month-day, not null */ public static MonthDay now(Clock clock) { final LocalDate now = LocalDate.now(clock); // called once return MonthDay.of(now.getMonth(), now.getDayOfMonth()); }
@Nonnull @Override public Date convert(LocalTime source) { return toDate(source.atDate(LocalDate.now()).atZone(systemDefault()).toInstant()); } }