/** * Get the year * * @return the year for this day */ public int getYear() { return date.getYear(); }
@Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(date.getYear()); dest.writeInt(date.getMonthValue()); dest.writeInt(date.getDayOfMonth()); }
@Override public String toString() { return "CalendarDay{" + date.getYear() + "-" + date.getMonthValue() + "-" + date.getDayOfMonth() + "}"; }
@Override public int hashCode() { return hashCode(date.getYear(), date.getMonthValue(), date.getDayOfMonth()); }
@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 ); }
@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()); }
/** * Reconstitutes this object from a stream. * * @param stream object input stream */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.era = JapaneseEra.from(isoDate); int yearOffset = this.era.startDate().getYear() - 1; this.yearOfEra = isoDate.getYear() - yearOffset; }
/** * Reconstitutes this object from a stream. * * @param stream object input stream */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.era = JapaneseEra.from(isoDate); int yearOffset = this.era.startDate().getYear() - 1; this.yearOfEra = isoDate.getYear() - yearOffset; }
@Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof JapaneseEra == false) { throw new ClassCastException("Era must be JapaneseEra"); } JapaneseEra jera = (JapaneseEra) era; int isoYear = jera.startDate().getYear() + yearOfEra - 1; ValueRange range = ValueRange.of(1, jera.endDate().getYear() - jera.startDate().getYear() + 1); range.checkValidValue(yearOfEra, YEAR_OF_ERA); return isoYear; }
@Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof JapaneseEra == false) { throw new ClassCastException("Era must be JapaneseEra"); } JapaneseEra jera = (JapaneseEra) era; int isoYear = jera.startDate().getYear() + yearOfEra - 1; ValueRange range = ValueRange.of(1, jera.endDate().getYear() - jera.startDate().getYear() + 1); range.checkValidValue(yearOfEra, YEAR_OF_ERA); return isoYear; }
/** * Converts a {@code LocalDate} to a {@code java.sql.Date}. * * @param date the local date, not null * @return the SQL date, not null */ @SuppressWarnings("deprecation") public static java.sql.Date toSqlDate(LocalDate date) { return new java.sql.Date(date.getYear() - 1900, date.getMonthValue() -1, date.getDayOfMonth()); }
/** * Converts a {@code LocalDate} to a {@code java.sql.Date}. * * @param date the local date, not null * @return the SQL date, not null */ @SuppressWarnings("deprecation") public static java.sql.Date toSqlDate(LocalDate date) { return new java.sql.Date(date.getYear() - 1900, date.getMonthValue() -1, date.getDayOfMonth()); }
/** * 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()); }
private int findYear(long epochSecond, ZoneOffset offset) { // inline for performance long localSecond = epochSecond + offset.getTotalSeconds(); long localEpochDay = Jdk8Methods.floorDiv(localSecond, 86400); return LocalDate.ofEpochDay(localEpochDay).getYear(); }
private int findYear(long epochSecond, ZoneOffset offset) { // inline for performance long localSecond = epochSecond + offset.getTotalSeconds(); long localEpochDay = Jdk8Methods.floorDiv(localSecond, 86400); return LocalDate.ofEpochDay(localEpochDay).getYear(); }
@Override public com.datastax.driver.core.LocalDate convert(LocalDate source) { return com.datastax.driver.core.LocalDate.fromYearMonthDay(source.getYear(), source.getMonthValue(), source.getDayOfMonth()); } }
/** * Obtains the current year-month from the specified clock. * <p> * This will query the specified clock to obtain the current year-month. * 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-month, not null */ public static YearMonth now(Clock clock) { final LocalDate now = LocalDate.now(clock); // called once return YearMonth.of(now.getYear(), now.getMonth()); }
private JapaneseDate resolveEYD(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle, JapaneseEra era, int yoe) { if (resolverStyle == ResolverStyle.LENIENT) { int y = era.startDate().getYear() + yoe - 1; long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_YEAR), 1); return dateYearDay(y, 1).plus(days, DAYS); } int doy = range(DAY_OF_YEAR).checkValidIntValue(fieldValues.remove(DAY_OF_YEAR), DAY_OF_YEAR); return dateYearDay(era, yoe, doy); // smart is same as strict }
private JapaneseDate resolveEYD(Map<TemporalField, Long> fieldValues, ResolverStyle resolverStyle, JapaneseEra era, int yoe) { if (resolverStyle == ResolverStyle.LENIENT) { int y = era.startDate().getYear() + yoe - 1; long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_YEAR), 1); return dateYearDay(y, 1).plus(days, DAYS); } int doy = range(DAY_OF_YEAR).checkValidIntValue(fieldValues.remove(DAY_OF_YEAR), DAY_OF_YEAR); return dateYearDay(era, yoe, doy); // smart is same as strict }