/** * Get the month, represented by values from {@linkplain LocalDate} * * @return the month of the year as defined by {@linkplain LocalDate} */ public int getMonth() { return date.getMonthValue(); }
@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()); }
/** * Gets the month-of-year field from 1 to 12. * <p> * This method returns the month as an {@code int} from 1 to 12. * Application code is frequently clearer if the enum {@link Month} * is used by calling {@link #getMonth()}. * * @return the month-of-year, from 1 to 12 * @see #getMonth() */ public int getMonthValue() { return date.getMonthValue(); }
/** * Gets the month-of-year field from 1 to 12. * <p> * This method returns the month as an {@code int} from 1 to 12. * Application code is frequently clearer if the enum {@link Month} * is used by calling {@link #getMonth()}. * * @return the month-of-year, from 1 to 12 * @see #getMonth() */ public int getMonthValue() { return date.getMonthValue(); }
private long getProlepticMonth() { return getProlepticYear() * 12L + isoDate.getMonthValue() - 1; }
private long getProlepticMonth() { return getProlepticYear() * 12L + isoDate.getMonthValue() - 1; }
private long getProlepticMonth() { return getProlepticYear() * 12L + isoDate.getMonthValue() - 1; }
private long getProlepticMonth() { return getProlepticYear() * 12L + isoDate.getMonthValue() - 1; }
@Override public int lengthOfYear() { Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE); jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth()); return jcal.getActualMaximum(Calendar.DAY_OF_YEAR); }
@Override public int lengthOfYear() { Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE); jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth()); return jcal.getActualMaximum(Calendar.DAY_OF_YEAR); }
/** * 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()); }
private ValueRange actualRange(int calendarField) { Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE); jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth()); return ValueRange.of(jcal.getActualMinimum(calendarField), jcal.getActualMaximum(calendarField)); }
private ValueRange actualRange(int calendarField) { Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE); jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth()); return ValueRange.of(jcal.getActualMinimum(calendarField), jcal.getActualMaximum(calendarField)); }
@Override public void serialize(LocalDate date, JsonGenerator generator, SerializerProvider provider) throws IOException { if (useTimestamp(provider)) { generator.writeStartArray(); generator.writeNumber(date.getYear()); generator.writeNumber(date.getMonthValue()); generator.writeNumber(date.getDayOfMonth()); generator.writeEndArray(); } else { String str = (_formatter == null) ? date.toString() : date.format(_formatter); generator.writeString(str); } }
@Override public com.datastax.driver.core.LocalDate convert(LocalDate source) { return com.datastax.driver.core.LocalDate.fromYearMonthDay(source.getYear(), source.getMonthValue(), source.getDayOfMonth()); } }
/** * Obtains a local date in Japanese calendar system from the * proleptic-year and day-of-year fields. * <p> * The day-of-year in this factory is expressed relative to the start of the proleptic year. * The Japanese proleptic year and day-of-year are the same as those in the ISO calendar system. * They are not reset when the era changes. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Japanese local date, not null * @throws DateTimeException if unable to create the date */ @Override public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) { LocalDate date = LocalDate.ofYearDay(prolepticYear, dayOfYear); return date(prolepticYear, date.getMonthValue(), date.getDayOfMonth()); }
/** * Obtains a local date in Japanese calendar system from the * proleptic-year and day-of-year fields. * <p> * The day-of-year in this factory is expressed relative to the start of the proleptic year. * The Japanese proleptic year and day-of-year are the same as those in the ISO calendar system. * They are not reset when the era changes. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Japanese local date, not null * @throws DateTimeException if unable to create the date */ @Override public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) { LocalDate date = LocalDate.ofYearDay(prolepticYear, dayOfYear); return date(prolepticYear, date.getMonthValue(), date.getDayOfMonth()); }