org.threeten.bp.LocalDate.now()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中org.threeten.bp.LocalDate.now()方法的一些代码示例,展示了LocalDate.now()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.now()方法的具体详情如下:
包路径:org.threeten.bp.LocalDate
类名称:LocalDate
方法名:now

LocalDate.now介绍

[英]Obtains the current date from the system clock in the default time-zone.

This will query the Clock#systemDefaultZone() in the default time-zone to obtain the current date.

Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
[中]从默认时区中的系统时钟获取当前日期。
这将查询默认时区中的时钟#systemDefaultZone(),以获取当前日期。
使用此方法将防止使用备用时钟进行测试,因为该时钟是硬编码的。

代码示例

代码示例来源:origin: prolificinteractive/material-calendarview

/**
 * Get a new instance set to today
 *
 * @return CalendarDay set to today's date
 */
@NonNull public static CalendarDay today() {
 return from(LocalDate.now());
}

代码示例来源:origin: prolificinteractive/material-calendarview

@Override
public void onBindViewHolder(EntryViewHolder holder, int position) {
 //set selected date to today
 holder.calendarView.setSelectedDate(LocalDate.now());
}

代码示例来源:origin: prolificinteractive/material-calendarview

@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;
}

代码示例来源:origin: prolificinteractive/material-calendarview

public StateBuilder() {
 calendarMode = CalendarMode.MONTHS;
 firstDayOfWeek =
   LocalDate.now().with(WeekFields.of(Locale.getDefault()).dayOfWeek(), 1).getDayOfWeek();
}

代码示例来源: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: 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(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: ThreeTen/threetenbp

/**
 * 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));
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * 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());
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * 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));
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * 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));
}

代码示例来源:origin: shrikanth7698/Collapsible-Calendar-View-Android

public boolean isToady(@NonNull LocalDate day) {
  return LocalDate.now().equals(day);
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * 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());
}

代码示例来源:origin: shrikanth7698/Collapsible-Calendar-View-Android

public CalendarAdapter(Context context) {
  this.mCal = LocalDate.now().withDayOfMonth(1);
  mInflater = LayoutInflater.from(context);
  refresh();
}

代码示例来源:origin: shrikanth7698/Collapsible-Calendar-View-Android

public LocalDate getSelectedDay() {
  if (getSelectedItem() == null) {
    return LocalDate.now();
  }
  return getSelectedItem();
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * 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));
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * 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());
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * 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());
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * 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());
}

代码示例来源:origin: apache/servicemix-bundles

@Nonnull
  @Override
  public Date convert(LocalTime source) {
    return toDate(source.atDate(LocalDate.now()).atZone(systemDefault()).toInstant());
  }
}

相关文章