@Override public void writeObject(ObjectOutput output, YearMonth value) throws IOException { output.writeInt(value.getYear()); DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, value.getMonth()); }
@Override public Integer convertToDatabaseColumn(YearMonth attribute) { return (attribute.getYear() * 100) + attribute.getMonth().getValue(); }
protected LocalDate toLocalDate(YearMonth yearMonth) { return LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1); }
if (dateCell == null || !(dayCellDate(dateCell).getMonth() == yearMonth.getMonth())) { dateCell = findDayCellOfDate(yearMonth.atDay(1));
public static void main(String[] args) { for (int i = 5; i >= 0; i--) { YearMonth date = YearMonth.now().minusMonths(i); String monthName = date.getMonth().getDisplayName(TextStyle.SHORT, Locale.ENGLISH); System.out.println(monthName + "(" + date.getYear() + ")"); } }
@Override public void integerTextFieldNumberChanged(JIntegerTextField source, int newValue) { YearMonth newYearMonth = YearMonth.of(newValue, displayedYearMonth.getMonth()); drawCalendar(newYearMonth); } };
@Override public void actionPerformed(ActionEvent e) { String chosenMenuText = ((JMenuItem) e.getSource()).getText(); int chosenYear = Integer.parseInt(chosenMenuText); drawCalendar(chosenYear, displayedYearMonth.getMonth()); } }));
private LocalDate getLocalDateFromYearAndMonth(final YearMonth yearMonth) { return LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1); } }
protected LocalDate toLocalDate(YearMonth yearMonth) { return LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1); }
protected LocalDate toLocalDate(YearMonth yearMonth) { return LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1); }
/** * Returns the length of the month, taking account of the year. * <p> * This returns the length of the month in days. * For example, a date in January would return 31. * * @return the length of the month in days, from 28 to 31 */ public int lengthOfMonth() { return getMonth().length(isLeapYear()); }
/** * getLastDayOfMonth, This returns the last day of the month for the specified year and month. * * Implementation notes: As of this writing, the below implementation is verified to work * correctly for negative years, as those years are to defined in the iso 8601 your format that * is used by java.time.YearMonth. This functionality can be tested by by checking to see if to * see if the year "-0004" is correctly displayed as a leap year. Leap years have 29 days in * February. There should be 29 days in the month of "February 1, -0004". */ private int getLastDayOfMonth(YearMonth yearMonth) { LocalDate firstDayOfMonth = LocalDate.of(yearMonth.getYear(), yearMonth.getMonth(), 1); int lastDayOfMonth = firstDayOfMonth.lengthOfMonth(); return lastDayOfMonth; }
YearMonth ym = ymStart; do { int daysInMonth = ym.lengthOfMonth (); String monthName = ym.getMonth ().getDisplayName ( TextStyle.FULL , Locale.CANADA_FRENCH ); System.out.println ( ym + " : " + daysInMonth + " jours en " + monthName ); // Prepare for next loop. ym = ym.plusMonths ( 1 ); } while ( ym.isBefore ( ymStop ) );
@Override public void writeObject(ObjectOutput output, YearMonth value) throws IOException { output.writeInt(value.getYear()); DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, value.getMonth()); }
private static void javaTime(Map<Class, ParamSetter> ss) { reg(ss, Instant.class, (param, ps, i) -> ps.setTimestamp(i, timestamp(param))); reg(ss, OffsetDateTime.class, (param, ps, i) -> ps.setTimestamp(i, timestamp(param.toInstant()))); reg(ss, ZonedDateTime.class, (param, ps, i) -> ps.setTimestamp(i, timestamp(param.toInstant()))); reg(ss, LocalDate.class, (param, ps, i) -> ps.setDate(i, java.sql.Date.valueOf(param))); reg(ss, LocalTime.class, (param, ps, i) -> ps.setTime(i, java.sql.Time.valueOf(param))); reg(ss, LocalDateTime.class, (param, ps, i) -> ps.setTimestamp(i, java.sql.Timestamp.valueOf(param))); reg(ss, Year.class, (param, ps, i) -> ps.setDate(i, java.sql.Date.valueOf(LocalDate.of(param.getValue(), Month.JANUARY, 1)))); reg(ss, YearMonth.class, (param, ps, i) -> ps.setDate(i, java.sql.Date.valueOf(LocalDate.of(param.getYear(), param.getMonth(), 1)))); }
@Override public void writeObject(ObjectOutput output, YearMonth value) throws IOException { output.writeInt(value.getYear()); DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, value.getMonth()); }
@Override public Integer convertToDatabaseColumn(YearMonth attribute) { return (attribute.getYear() * 100) + attribute.getMonth().getValue(); }
@Override public Integer convertToDatabaseColumn(YearMonth attribute) { return (attribute.getYear() * 100) + attribute.getMonth().getValue(); }
@Override public Integer convertToDatabaseColumn(YearMonth attribute) { return (attribute.getYear() * 100) + attribute.getMonth().getValue(); }
private static DoubleArray seasonalityCompounded( LocalDate valDate, YearMonth fixingMonth, DoubleArray seasonality, DoubleBinaryOperator adjustmentFunction) { double nbMonths = YearMonth.from(valDate).until(fixingMonth, MONTHS); double[] seasonalityCompoundedArray = new double[12]; int lastMonthIndex = fixingMonth.getMonth().getValue() - 2; seasonalityCompoundedArray[(int) ((nbMonths + 12 + 1) % 12)] = seasonality.get((lastMonthIndex + 1) % 12); for (int i = 1; i < 12; i++) { int j = (int) ((nbMonths + 12 + 1 + i) % 12); seasonalityCompoundedArray[j] = adjustmentFunction.applyAsDouble( seasonalityCompoundedArray[(j - 1 + 12) % 12], seasonality.get((lastMonthIndex + 1 + i) % 12)); } return DoubleArray.ofUnsafe(seasonalityCompoundedArray); }