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

加减月份的问题 #1

Open
smaiiboy opened this issue Aug 2, 2017 · 1 comment
Open

加减月份的问题 #1

smaiiboy opened this issue Aug 2, 2017 · 1 comment

Comments

@smaiiboy
Copy link

smaiiboy commented Aug 2, 2017

DateFormat.addMonth(date, 1); DateFormat.addMonth(date, -1);
加月份时,如果当前日期为8月31号,返回的时间为10月1号
减月份时,日期为7月31号,返回7月1号

@hellolex
Copy link

这个问题我也遇到了
假设date = Thu May 31 2018 09:56:22 GMT+0800 (中国标准时间)
addMonth(date, -1) 返回的是Tue May 01 2018 09:56:22 GMT+0800 (中国标准时间)
addMonth(date, -2) 返回的是Sat Mar 31 2018 09:56:22 GMT+0800 (中国标准时间) 符合预期
addMonth(date, 1) 返回的是Sun Jul 01 2018 09:56:22 GMT+0800 (中国标准时间) 符合预期
addMonth(date, 2) 返回的是Tue Jul 31 2018 09:56:22 GMT+0800 (中国标准时间)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants