Skip to content

[Bug] Numeric cells fail to read into java.time.Year ("Converter not found") #1216

Closed

Description

@Mikkey-f

Search before asking

  • I searched in the issues and found nothing similar.

Fesod version

main

JDK version

any

Operating system

any

Steps To Reproduce

// a file whose "year" column is a plain number
File file = new File("year.xlsx");
try (XSSFWorkbook workbook = new XSSFWorkbook(); OutputStream out = new FileOutputStream(file)) {
    XSSFSheet sheet = workbook.createSheet("Sheet1");
    sheet.createRow(0).createCell(0).setCellValue("year");
    sheet.createRow(1).createCell(0).setCellValue(2026.0);
    workbook.write(out);
}

// the POJO
public class YearHolder {
    @ExcelProperty("year")
    private Year year;
}

// the read
FesodSheet.read(file).head(YearHolder.class).sheet().doReadSync();

Current Behavior

ExcelDataConvertException: Error at row 1, column 0: Converter not found, convert NUMBER to java.time.Year

The read fails outright — a single numeric cell aborts the sheet. Date-formatted numeric cells (e.g. a real 2026-01-01 cell) fail the same way, since they are NUMBER cells at read time.

Expected Behavior

The value reads as Year.of(2026). Sibling date-like types already support numeric cells: LocalDate, LocalTime and java.util.Date each ship a ...NumberConverter, so a numeric cell reads into those fields fine — java.time.Year (added in #1087) only ships YearStringConverter, which leaves the (Year, NUMBER) key unmapped.

Anything else?

  • Workaround today: declare the field as String/Integer, or register a custom Converter<Year> — there is no built-in path.

  • Asymmetry worth noting: writing a Year field through fesod produces a STRING cell ("2026"), so fesod's own round-trip works; numeric year columns from any other source fail.

  • Suggested semantics for a YearNumberConverter (happy to implement):

    • date-formatted cell → read the serial as a date and take its year (consistent with the sibling converters);
    • plain numeric cell → treat the number as the year (2026 → Year.of(2026); a serial reading would give 1905, which is not what a year column means).

    If the project prefers strict family consistency (serial semantics everywhere), I can implement that instead — the design call is the maintainers'.

  • I searched the tracker: no existing issue covers this.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. bengbengbalabalabeng commented on Oct 12, 2026

    @bengbengbalabalabeng
    Contributor

    Thanks for raising this.

    The current behavior is expected because there is no built-in converter for java.time.Year yet. Therefore, this seems more like an enhancement request rather than a bug report.

    Since the broader discussion about adding converters for additional java.time types is already tracked in #1017, it would be better to continue the discussion there.

  2. Mikkey-f commented on Oct 12, 2026

    @Mikkey-f
    ContributorAuthor

    Agreed on both points — thanks for the steer.

    With Year shipping only the STRING converter from #1087, the (Year, NUMBER) read key is unmapped, so the read takes the standard "converter not found" path — a missing converter rather than a defect. I've moved the proposal to #1017 as you suggested.

    The implementation is already up as #1217 (opened earlier today, before the reclassification), now relinked and retitled as a #1017 slice rather than a bug fix. Since the work is now tracked under #1017, I'll close this issue in favor of it — easy to reopen if you'd rather keep it as the record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions