Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

希望为DateTimeFormat增加时区参数 #841

Open
DoneSpeak opened this issue Nov 14, 2019 · 6 comments
Open

希望为DateTimeFormat增加时区参数 #841

DoneSpeak opened this issue Nov 14, 2019 · 6 comments
Labels
planning It may be developed later suggest Suggest

Comments

@DoneSpeak
Copy link

建议描述

对于时间的处理,处理需要时间格式,同时还需要时区的设置。服务器的位置不一定都在中国,也可能在国外,不同的时区。如果不指定时区,必定会导致输出的数据不正确。

@DoneSpeak DoneSpeak added the suggest Suggest label Nov 14, 2019
@DoneSpeak
Copy link
Author

DoneSpeak commented Nov 14, 2019

我感觉只要对DateTimeFormat, DateTimeFormatProperty, DateStringConverterDateNumberConverter 进行简单的拓展应该就可以了。

我现在自己的做法是增加一个自定义的@DateTimeZone 并重写了 DateStringConverterDateNumberConverter,事实上也重写了com.alibaba.excel.util.DateUtilsDateUtils没有考虑到对TimeZone的支持,只能重写了。

然后覆盖了原来处理的Date的Converter。

EasyExcel.write(file, Birthday.class)
            .registerConverter(new TimeZoneStringConverter("US/Central"))
            .sheet("birthday").doWrite(birthdayList);

@zhuangjiaju zhuangjiaju added the developing This feature will be added in future releases label Nov 14, 2019
@zhuangjiaju
Copy link
Collaborator

后续考虑加入

@BonjourL
Copy link

也遇到这种问题了

@chengfan2017
Copy link

application填写这个方法就可以了
@PostConstruct
void started() {
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
}

@zhuangjiaju
Copy link
Collaborator

这个建议设置全局默认时间即可

@zhuangjiaju zhuangjiaju reopened this Sep 17, 2021
@zhuangjiaju zhuangjiaju added planning It may be developed later and removed developing This feature will be added in future releases labels Sep 17, 2021
@xyllq999
Copy link

请问一下如何设置全局默认时间呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
planning It may be developed later suggest Suggest
Projects
None yet
Development

No branches or pull requests

5 participants