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

[BUG]日期格式化问题 #1497

Closed
zacat opened this issue May 19, 2023 · 1 comment
Closed

[BUG]日期格式化问题 #1497

zacat opened this issue May 19, 2023 · 1 comment
Labels
bug Something isn't working fixed
Milestone

Comments

@zacat
Copy link

zacat commented May 19, 2023

问题描述

简要描述您碰到的问题。

环境信息

请填写以下信息:

  • OS信息: [e.g.:Windows 10]
  • JDK信息: [e.g.:Openjdk 19]
  • 版本信息:[e.g.:Fastjson2 2.0.32]

日期输出
2023-05-19 通过 JSONWriterUTF8.writeDateYYYMMDD10 函数后变成 20230519

修改前
@OverRide
public final void writeDateYYYMMDD10(int year, int month, int dayOfMonth) {
int minCapacity = off + 12;
if (minCapacity >= bytes.length) {
ensureCapacity(minCapacity);
}

    bytes[off++] = (byte) quote;
    write4(year, bytes, off);
    off += 4;
    bytes[off + 5] = '-';
    write2(month, bytes, off);
    off += 2;
    bytes[off + 8] = '-';
    write2(dayOfMonth, bytes, off);
    off += 2;
    bytes[off++] = (byte) quote;
}

修改后
@OverRide
public final void writeDateYYYMMDD10(int year, int month, int dayOfMonth) {
int minCapacity = off + 12;
if (minCapacity >= bytes.length) {
ensureCapacity(minCapacity);
}

    bytes[off++] = (byte) quote;
    write4(year, bytes, off);
    off += 4;
    bytes[off++] = '-';
    write2(month, bytes, off);
    off += 2;
    bytes[off++] = '-';
    write2(dayOfMonth, bytes, off);
    off += 2;
    bytes[off++] = (byte) quote;
}
@zacat zacat added the bug Something isn't working label May 19, 2023
@wenshao
Copy link
Member

wenshao commented May 19, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.33-SNAPSHOT/
问题已修复,请帮忙用2.0.33-SNAPSHOT版本验证。

@wenshao wenshao added this to the 2.0.33 milestone May 19, 2023
@wenshao wenshao added the fixed label May 19, 2023
@zacat zacat closed this as completed May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants