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

@JSONField如何兼容多个格式 #2436

Open
shixiayu13 opened this issue Apr 12, 2024 · 2 comments
Open

@JSONField如何兼容多个格式 #2436

shixiayu13 opened this issue Apr 12, 2024 · 2 comments
Labels
question Further information is requested

Comments

@shixiayu13
Copy link

@JSONField(format = "yyyy-MM-dd HH:mm:ss")
同时支持:yyyy-MM-dd HH:mm
需要怎么操作

@shixiayu13 shixiayu13 added the question Further information is requested label Apr 12, 2024
@wenshao
Copy link
Member

wenshao commented Apr 13, 2024

请帮忙构造重现问题的testcase

@wenshao
Copy link
Member

wenshao commented May 12, 2024

    @Test
    public void test() {
        String str = JSONObject.of("date", "2024-06-14 12:13:00").toJSONString();
        String str1 = JSONObject.of("date", "2024-06-14 12:13").toJSONString();
        Date date = JSON.parseObject(str, Bean.class).date;
        Date date1 = JSON.parseObject(str1, Bean.class).date;
        assertEquals(date.getTime(), date1.getTime());
    }

    public static class Bean {
        @JSONField(format = "yyyy-MM-dd HH:mm:ss")
        public Date date;
    }

问题未重现

wenshao added a commit that referenced this issue May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants