Skip to content

[Bug] WriteCellData 方法如果传入 java.sql.Date 会报错 #714

@kt286

Description

@kt286

Search before asking

  • I searched in the issues and found nothing similar.

Fesod version

1.3.0

JDK version

17

Operating system

No response

Steps To Reproduce

Mybatis 3.5.17 之后的版本,date类型的数据返回的是 java.sql.Date 而不是 java.util.Date,此时在 WriteCellData 方法中调用 dateValue.toInstant() 会报错

    /**
     * Constructor for creating a WriteCellData object with a Date value.
     *
     * @param dateValue The Date value to be written to the cell.
     * @throws IllegalArgumentException If the date value is null.
     */
    public WriteCellData(Date dateValue) {
        super();
        if (dateValue == null) {
            throw new IllegalArgumentException("DateValue can not be null");
        }
        setType(CellDataTypeEnum.DATE);
        this.dateValue = LocalDateTime.ofInstant(dateValue.toInstant(), ZoneId.systemDefault());
    }

参考链接
mybatis/mybatis-3@28af7e9#diff-3100284b93f6e47f7e09229bac897dc14edbb2e162002f24e804113f49d8b6a6R44-R52

Image Image

Current Behavior

throw new java.lang.UnsupportedOperationException();

Expected Behavior

正常

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions